5. Same in Maven
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.liferay.sample</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
6. The Project Object Model
• Analogous to Makefile or build.xml
• Versioned <major>.<minor>.<increment>-<qualifier>
• Packaging (pom, jar, war, ejb, ear, etc.)
• Inheritance
• Sub-modules
• Dependencies
• Profiles
• Properties
7. Dependency Management
• Declarative
• Transitive
• Identified by: groupId, artifactId, version and type
combination
• Scoped: compile, provided, runtime, test or system
8. Build Lifecycle
• Build-in lifecycles: default, clean and site
• Lifecycles have phases
• Goals are attached to phases
• Common phases:
• clean
• compile
• test
• package
• install
• deploy
9. Repositories
• Place where all artifacts are stored
• Local
• Located in USER_HOME/.m2/repository
• Cached copy of downloaded artifacts
• Contains locally installed artifacts
• Remote
• Central
• Internal or external
• Proxy or Cache
10. What is Artifact?
• Product of build
• Described by pom.xml
• Identified with combination of groupId, artifactId, version
and qualifier
11. What is Archetype?
• Project template
• Available for various project types
• Run mvn archetype:generate to create interactively or
specify with parameters
mvn archetype:generate
-DarchetypeArtifactId=liferay-portlet-archetype
-DarchetypeGroupId=com.liferay.maven.archetypes
-DarchetypeVersion=6.1.0
-DgroupId=com.liferay.sample
-DartifactId=sample-portlet
-Dversion=1.0-SNAPSHOT
-DinteractiveMode=false
12. Liferay Maven Support
• Alternative to ant based plugins sdk
• Compatible with both Liferay 6.1 CE and EE
• CE Portal Artifacts published to Maven Central
Repository
• EE Portal Artifacts downloadable from Customer Portal
• Liferay Maven Plugin and Archetypes published to Maven
Central Repository for both CE and EE
18. Parent Project
• Vaguely equivalent to plugins sdk instance
• Includes all the project modules such as:
• Portlets
• Themes
• Layouts
• Contains common project properties such as used Liferay
version
20. Theme Module
• Merges with parent theme
during packaging
• Parent theme defined in
pom.xml
• Parent can be built-in theme
or any war artifact
• Deploy with
mvn liferay:deploy
or
mvn liferay:direct-deploy -DdeployDir=/
opt/liferay/tomcat/webapps
21. Service Builder Module
• Creates separate portlet and
service api sub projects
• Build service from -portlet
mvn liferay:build-service
• Deploy from -portlet
mvn liferay:deploy
or
mvn liferay:direct-deploy -DdeployDir=/
opt/liferay/tomcat/webapps
22. Ext Plugin Module
• Similar structure to plugins
sdk but mavenized
• Build service from -ext-impl
mvn liferay:build-service
-DserviceFileName=src/main/resources/
com/liferay/sample/service.xml
• Deploy from -ext
mvn liferay:build-service
-DserviceFileName=src/main/resources/
com/liferay/sample/service.xml
23. Maven Best Practices
• Setup internal repository and maven proxy
• Reduces build time by caching dependencies
• Increases build stability and repeatability
• Allows enforcing company policies
• Never use 3rd party SNAPHOT dependencies
• Declare all your dependencies and don’t rely on transitive
dependencies for classes you use
24. Future Plans
• IDE integration
• Liferay IDE
• Liferay Developer Studio
• More archetypes (liferay faces, spring mvc, etc.)
• Liferay Bundle Builder