Your SlideShare is downloading. ×
0
Developing Liferay Plugins withMavenMika KoivistoSenior Software Engineer
Agenda•   Quick Introduction to Maven•   Liferay Maven Support•   Demo•   Future Plans
Quick Introduction to Maven• Project management tool (build, test, report, assemble,    release)•   Small core expandable ...
Typical Ant build.xml<project name="my-project" default="dist" basedir=".">    <property name="src" location="src/main/jav...
Same in Maven<project>    <modelVersion>4.0.0</modelVersion>    <groupId>com.liferay.sample</groupId>    <artifactId>my-pr...
The Project Object Model•   Analogous to Makefile or build.xml•   Versioned <major>.<minor>.<increment>-<qualifier>•   Pac...
Dependency Management• Declarative• Transitive• Identified by: groupId, artifactId, version and type  combination• Scoped:...
Build Lifecycle•   Build-in lifecycles: default, clean and site•   Lifecycles have phases•   Goals are attached to phases•...
Repositories• Place where all artifacts are stored• Local  • Located in USER_HOME/.m2/repository  • Cached copy of downloa...
What is Artifact?• Product of build• Described by pom.xml• Identified with combination of groupId, artifactId, version  an...
What is Archetype?• Project template• Available for various project types• Run mvn archetype:generate to create interactiv...
Liferay Maven Support• Alternative to ant based plugins sdk• Compatible with both Liferay 6.1 CE and EE• CE Portal Artifac...
Liferay Portal Artifacts• GroupId: com.liferay.portal• ArtifactId:  • portal-client  • portal-impl  • portal-service  • po...
Liferay Maven Plugin• GroupId: com.liferay.maven.plugins• ArtifactId: liferay-maven-plugin• Brings features from Plugins S...
Liferay Maven Plugin Goals•   liferay:build-ext•   liferay:build-lang•   liferay:build-service•   liferay:build-thumbnail•...
Liferay Archetypes• GroupId: com.liferay.maven.archetypes• ArtifactId:  • liferay-ext-archetype  • liferay-hook-archetype ...
Demo
Parent Project• Vaguely equivalent to plugins sdk instance• Includes all the project modules such as:  • Portlets  • Theme...
Sample Parent Project Pom<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in...
Theme Module• Merges with parent theme     during packaging• Parent theme defined in     pom.xml• Parent can be built-in t...
Service Builder Module• Creates separate portlet and     service api sub projects• Build service from -portletmvn liferay:...
Ext Plugin Module• Similar structure to plugins   sdk but mavenized• Build service from -ext-implmvn liferay:build-service...
Maven Best Practices• Setup internal repository and maven proxy  • Reduces build time by caching dependencies  • Increases...
Future Plans• IDE integration  • Liferay IDE  • Liferay Developer Studio• More archetypes (liferay faces, spring mvc, etc....
Contributing• Github project  https://github.com/liferay/liferay-maven-support• JIRA  http://issues.liferay.com/browse/MAVEN
Contact Email: mika.koivisto@liferay.com Twitter: @koivimik Github: mikakoivisto
Upcoming SlideShare
Loading in...5
×

Developing Liferay Plugins with Maven

13,944

Published on

My Maven presentation on Liferay Nordic Symposium 2012

Published in: Technology
3 Comments
8 Likes
Statistics
Notes
No Downloads
Views
Total Views
13,944
On Slideshare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
228
Comments
3
Likes
8
Embeds 0
No embeds

No notes for slide

Transcript of "Developing Liferay Plugins with Maven"

  1. 1. Developing Liferay Plugins withMavenMika KoivistoSenior Software Engineer
  2. 2. Agenda• Quick Introduction to Maven• Liferay Maven Support• Demo• Future Plans
  3. 3. Quick Introduction to Maven• Project management tool (build, test, report, assemble, release)• Small core expandable with plugins• Convention over configuration• Dependency management• Common lifecycle
  4. 4. Typical Ant build.xml<project name="my-project" default="dist" basedir="."> <property name="src" location="src/main/java"/> <property name="build" location="target/classes"/> <property name="dist" location="target"/> <target name="init"> <tstamp/> <mkdir dir="${build}"/> </target> <target name="compile" depends="init" description="compile the source " > <javac srcdir="${src}" destdir="${build}"/> </target> <target name="dist" depends="compile"> <mkdir dir="${dist}/lib"/> <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/> </target> <target name="clean"> <delete dir="${build}"/> <delete dir="${dist}"/> </target></project>
  5. 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. 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. 7. Dependency Management• Declarative• Transitive• Identified by: groupId, artifactId, version and type combination• Scoped: compile, provided, runtime, test or system
  8. 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. 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. 10. What is Artifact?• Product of build• Described by pom.xml• Identified with combination of groupId, artifactId, version and qualifier
  11. 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. 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
  13. 13. Liferay Portal Artifacts• GroupId: com.liferay.portal• ArtifactId: • portal-client • portal-impl • portal-service • portal-web • support-tomcat • util-bridges • util-java • util-taglib
  14. 14. Liferay Maven Plugin• GroupId: com.liferay.maven.plugins• ArtifactId: liferay-maven-plugin• Brings features from Plugins SDK to Maven • Service Builder • Theme diffs • Direct Deployment
  15. 15. Liferay Maven Plugin Goals• liferay:build-ext• liferay:build-lang• liferay:build-service• liferay:build-thumbnail• liferay:build-wsdd• liferay:deploy• liferay:direct-deploy• liferay:theme-merge
  16. 16. Liferay Archetypes• GroupId: com.liferay.maven.archetypes• ArtifactId: • liferay-ext-archetype • liferay-hook-archetype • liferay-layouttpl-archetype • liferay-portlet-archetype • liferay-servicebuilder-archetype • liferay-theme-archetype • liferay-web-archetype
  17. 17. Demo
  18. 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
  19. 19. Sample Parent Project Pom<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.liferay.sample</groupId> <artifactId>helloworld-project</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <properties> <liferay.version>6.1.10</liferay.version> <liferay.auto.deploy.dir>/opt/liferay-portal-6.1.10-ee-ga1/deploy</liferay.auto.deploy.dir> </properties></project>
  20. 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 withmvn liferay:deployormvn liferay:direct-deploy -DdeployDir=/opt/liferay/tomcat/webapps
  21. 21. Service Builder Module• Creates separate portlet and service api sub projects• Build service from -portletmvn liferay:build-service• Deploy from -portletmvn liferay:deployormvn liferay:direct-deploy -DdeployDir=/opt/liferay/tomcat/webapps
  22. 22. Ext Plugin Module• Similar structure to plugins sdk but mavenized• Build service from -ext-implmvn liferay:build-service-DserviceFileName=src/main/resources/com/liferay/sample/service.xml• Deploy from -extmvn liferay:build-service-DserviceFileName=src/main/resources/com/liferay/sample/service.xml
  23. 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. 24. Future Plans• IDE integration • Liferay IDE • Liferay Developer Studio• More archetypes (liferay faces, spring mvc, etc.)• Liferay Bundle Builder
  25. 25. Contributing• Github project https://github.com/liferay/liferay-maven-support• JIRA http://issues.liferay.com/browse/MAVEN
  26. 26. Contact Email: mika.koivisto@liferay.com Twitter: @koivimik Github: mikakoivisto
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×