SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Developing Liferay Plugins with
Maven
Mika Koivisto
Senior 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 with plugins
•   Convention over configuration
•   Dependency management
•   Common lifecycle
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>
Same in Maven
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.liferay.sample</groupId>
    <artifactId>my-project</artifactId>
    <version>1.0-SNAPSHOT</version>
</project>
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
Dependency Management
• Declarative
• Transitive
• Identified by: groupId, artifactId, version and type
  combination
• Scoped: compile, provided, runtime, test or system
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
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
What is Artifact?
• Product of build
• Described by pom.xml
• Identified with combination of groupId, artifactId, version
  and qualifier
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
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
Liferay Portal Artifacts
• GroupId: com.liferay.portal
• ArtifactId:
  • portal-client
  • portal-impl
  • portal-service
  • portal-web
  • support-tomcat
  • util-bridges
  • util-java
  • util-taglib
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
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
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
Demo
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
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>
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
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
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
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
Future Plans
• IDE integration
  • Liferay IDE
  • Liferay Developer Studio
• More archetypes (liferay faces, spring mvc, etc.)
• Liferay Bundle Builder
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

Weitere ähnliche Inhalte

Was ist angesagt?

2011.06.20 stratified-btree
2011.06.20 stratified-btree2011.06.20 stratified-btree
2011.06.20 stratified-btree
Acunu
 
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
devCAT Studio, NEXON
 

Was ist angesagt? (20)

Comparing high availability solutions with percona xtradb cluster and percona...
Comparing high availability solutions with percona xtradb cluster and percona...Comparing high availability solutions with percona xtradb cluster and percona...
Comparing high availability solutions with percona xtradb cluster and percona...
 
PGDay UK 2016 -- Performace for queries with grouping
PGDay UK 2016 -- Performace for queries with groupingPGDay UK 2016 -- Performace for queries with grouping
PGDay UK 2016 -- Performace for queries with grouping
 
실전 서버 부하테스트 노하우
실전 서버 부하테스트 노하우 실전 서버 부하테스트 노하우
실전 서버 부하테스트 노하우
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginners
 
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
 
Optimizing queries MySQL
Optimizing queries MySQLOptimizing queries MySQL
Optimizing queries MySQL
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
 
How to size up an Apache Cassandra cluster (Training)
How to size up an Apache Cassandra cluster (Training)How to size up an Apache Cassandra cluster (Training)
How to size up an Apache Cassandra cluster (Training)
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
C* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
C* Summit 2013: How Not to Use Cassandra by Axel LiljencrantzC* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
C* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
 
那些年學校沒教的 IT 事《系列一》從pc player到 IT Pro 之路
那些年學校沒教的 IT 事《系列一》從pc player到 IT Pro 之路那些年學校沒教的 IT 事《系列一》從pc player到 IT Pro 之路
那些年學校沒教的 IT 事《系列一》從pc player到 IT Pro 之路
 
서버 성능에 대한 정의와 이해
서버 성능에 대한 정의와 이해서버 성능에 대한 정의와 이해
서버 성능에 대한 정의와 이해
 
Toi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dungToi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dung
 
The Ceph RGW archive zone feature (Ceph Days 2019)
The Ceph RGW archive zone feature (Ceph Days 2019)The Ceph RGW archive zone feature (Ceph Days 2019)
The Ceph RGW archive zone feature (Ceph Days 2019)
 
2011.06.20 stratified-btree
2011.06.20 stratified-btree2011.06.20 stratified-btree
2011.06.20 stratified-btree
 
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming Patterns
 
MMUG18 - MySQL Failover and Orchestrator
MMUG18 - MySQL Failover and OrchestratorMMUG18 - MySQL Failover and Orchestrator
MMUG18 - MySQL Failover and Orchestrator
 
database backup and recovery
database backup and recoverydatabase backup and recovery
database backup and recovery
 

Andere mochten auch

Andere mochten auch (20)

Liferay Developer Best Practices for a Successful Deployment
Liferay Developer Best Practices for a Successful DeploymentLiferay Developer Best Practices for a Successful Deployment
Liferay Developer Best Practices for a Successful Deployment
 
J2EE Technology Mapping-21-may-2014
J2EE Technology Mapping-21-may-2014J2EE Technology Mapping-21-may-2014
J2EE Technology Mapping-21-may-2014
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open Discussion
 
Liferay Portal Introduction
Liferay Portal IntroductionLiferay Portal Introduction
Liferay Portal Introduction
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
OOD Principles and Patterns
OOD Principles and PatternsOOD Principles and Patterns
OOD Principles and Patterns
 
Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay way
 
SAML and Liferay
SAML and LiferaySAML and Liferay
SAML and Liferay
 
SaaS Introduction-May2014
SaaS Introduction-May2014SaaS Introduction-May2014
SaaS Introduction-May2014
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Portets to composite applications
Portets to composite applicationsPortets to composite applications
Portets to composite applications
 
Maven plugin guide using Modello Framework
Maven plugin guide using Modello FrameworkMaven plugin guide using Modello Framework
Maven plugin guide using Modello Framework
 
Alfresco P Tardif V1 0 Mars 2009
Alfresco   P Tardif V1 0   Mars 2009Alfresco   P Tardif V1 0   Mars 2009
Alfresco P Tardif V1 0 Mars 2009
 
7 plugins de la communauté à ne pas manquer ! - Liferay France Symposium 2016
7 plugins de la communauté à ne pas manquer ! - Liferay France Symposium 20167 plugins de la communauté à ne pas manquer ! - Liferay France Symposium 2016
7 plugins de la communauté à ne pas manquer ! - Liferay France Symposium 2016
 
Portal Presention
Portal PresentionPortal Presention
Portal Presention
 
EclipseCon Europe 2015 - liferay modularity patterns using OSGi -Rafik Harabi
EclipseCon Europe 2015 - liferay modularity patterns using OSGi -Rafik HarabiEclipseCon Europe 2015 - liferay modularity patterns using OSGi -Rafik Harabi
EclipseCon Europe 2015 - liferay modularity patterns using OSGi -Rafik Harabi
 
Chatbot in Sale Management
Chatbot in Sale ManagementChatbot in Sale Management
Chatbot in Sale Management
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Introduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay PortalIntroduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay Portal
 
Présentation Ippon DGA Liferay Symposium 2011
Présentation Ippon DGA Liferay Symposium 2011Présentation Ippon DGA Liferay Symposium 2011
Présentation Ippon DGA Liferay Symposium 2011
 

Ähnlich wie Developing Liferay Plugins with Maven

How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
Fazreil Amreen Abdul Jalil
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 

Ähnlich wie Developing Liferay Plugins with Maven (20)

Maven
MavenMaven
Maven
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
 
Session 2
Session 2Session 2
Session 2
 
Session 2
Session 2Session 2
Session 2
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Developing Liferay Plugins with Maven

  • 1. Developing Liferay Plugins with Maven Mika Koivisto Senior Software Engineer
  • 2. Agenda • Quick Introduction to Maven • Liferay Maven Support • Demo • Future Plans
  • 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. 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. 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
  • 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. 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. 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. 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. Demo
  • 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. 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. 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
  • 25. Contributing • Github project https://github.com/liferay/liferay-maven-support • JIRA http://issues.liferay.com/browse/MAVEN
  • 26. Contact Email: mika.koivisto@liferay.com Twitter: @koivimik Github: mikakoivisto