SlideShare une entreprise Scribd logo
1  sur  20
Liferay Maven SDK

Mika Koivisto
Senior Software Engineer
What is Maven?
  Project management tool
    Build, test, report, assemble, release
  Small core expandable with plugins
  Project Object Model (POM)
  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 pom.xml
<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>.<incremental>-<qualifier>
  Packaging (pom, jar, war, ejb, ear, etc.)
  Inheritance
  Multi-module
  Dependencies
  Profiles
  Properties
Dependency Management
  Declarative
  Transitive
  Identified by: groupId, artifactId, version and type
  combination
  Scoped: compile, provided, runtime, test or system
  Coping with 3rd party dependencies
Dependency Management
Build Lifecycle
  Three standard lifecycles: clean, default and site
  Lifecycles have phases
  Goals are attached to phases
  Lifecycle phases differs based on package type
  Common goals:
    process-resources, compile
    process-test-resources, test-compile, test
    install, deploy
Repositories
  Place where all artifacts are stored
  Local
    Locate in USER_HOME/.m2/repository
    Cached copy of remote downloads
    May contain project locally built artifacts
  Remote
    Central (repo1.maven.org), internal or external
    Proxy or Cache
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-SNAPSHOT 
  -DgroupId=com.liferay.sample 
  -DartifactId=sample-portlet 
  -Dversion=1.0-SNAPSHOT 
  -DinteractiveMode=false
Liferay and Maven
  Goal is to make maven a first class citizen in Liferay
  plugin development (alternative to ant based sdk)
  No Liferay core will not be built with maven, for now :-)
  Inspired by a community members effort in 5.2.3 (Milen
  Dyankov)
  Mostly developed by Me and Thiago Moreira with
  community feedback and patches
Current state
  CE artifacts published to Central through Sonatypes
  repository
  Artifacts: portal-client, portal-impl, portal-service, portal-
  web, tunnel-web, util-bridges, util-java and util-taglib
  Artifacts include javadoc and source archives
  Archetypes for hook, ext, layouttpl, portlet,
  servicebuilder, theme and web
Current state
  Plugins: ExtBuilder, LangBuilder, PluginDeployer,
  PluginDirectDeployer, ServiceBuilder, ThemeMerger,
  ThumbnailBuilder and WSDDBuilder
  All plugins package in one maven plugin package
  liferay-maven-plugin
  Maven 2.2.x compatible
  Some issues with Maven 3.0.x
Liferay EE and Maven
  Problematic because EE artifacts are not published to
  public repositories
  Building EE artifacts from source also not possible
  because EE source does not have build scripts
  Solution: Provide prebuilt package with install script to
  install them in either local repository or internal remote
  repository like Sonatype Nexus
Installing artifacts locally
   In Liferay portal source (not needed once released)
   ant -f build-maven.xml zip-maven
   Unzip liferay-portal-maven-<version>.zip
   Install artifacts by running
   ant install
   Deploy to repository (optional)
     Edit lp.maven.repository.url in build.properties
     Run ant deploy
Creating a portlet
 mvn archetype:generate
 -DarchetypeArtifactId=liferay-portlet-archetype
 -DarchetypeGroupId=com.liferay.maven.archetypes
 -DarchetypeVersion=6.1.0-SNAPSHOT
 -DarchetypeCatalog=local,remote
 -DartifactId=sample-portlet
 -DgroupId=com.liferay.sample
 -Dversion=1.0-SNAPSHOT
Maven Best Practices
  Setup internal repository and maven proxy
    Reduces build time by caching dependencies
    Increases build stability and repeatability
    Allows enforcing rules regarding allowed libraries
  Never use 3rd party SNAPHOT dependencies
  Declare your dependencies and don’t rely on transitive
  dependencies for libraries that you need
Resources
  Maven: The Complete Reference
  http://www.sonatype.com/books/mvnref-book/reference/

  Maven by Example
  http://www.sonatype.com/books/mvnex-book/reference/

  Maven homepage
  http://maven.apache.org

  My maven incubator - bleeding edge and some extras
  https://github.com/mikakoivisto/liferay-maven-incubation
Credits
 Figures from Maven: The Complete Reference by
 Sonatype, Inc.
 http://www.sonatype.com/books/mvnref-book/reference/
Thank You!

Contenu connexe

Tendances

Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenGeert Pante
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2andyhot
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and AntDavid Noble
 

Tendances (19)

Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Maven
MavenMaven
Maven
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Maven
MavenMaven
Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in Maven
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Maven
MavenMaven
Maven
 

En vedette

Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay wayriround
 
Portets to composite applications
Portets to composite applicationsPortets to composite applications
Portets to composite applicationsSerge Huber
 
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 HarabiRafik HARABI
 
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 Deploymentrivetlogic
 
Introduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay PortalIntroduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay Portalrivetlogic
 

En vedette (6)

Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay way
 
Portets to composite applications
Portets to composite applicationsPortets to composite applications
Portets to composite applications
 
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
 
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
 
Introduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay PortalIntroduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay Portal
 

Similaire à Liferay maven sdk

Similaire à Liferay maven sdk (20)

Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Mavenppt
MavenpptMavenppt
Mavenppt
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Maven
MavenMaven
Maven
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Maven with Flex
Maven with FlexMaven with Flex
Maven with Flex
 
Maven with Flex
Maven with FlexMaven with Flex
Maven with Flex
 
Maven
MavenMaven
Maven
 
intellimeet
intellimeetintellimeet
intellimeet
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
 
Maven
MavenMaven
Maven
 

Dernier

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
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.pdfsudhanshuwaghmare1
 
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 2024The Digital Insurer
 
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 businesspanagenda
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
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 FresherRemote DBA Services
 
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...DianaGray10
 
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 SavingEdi Saputra
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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, Adobeapidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Dernier (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
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
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Liferay maven sdk

  • 1. Liferay Maven SDK Mika Koivisto Senior Software Engineer
  • 2. What is Maven? Project management tool Build, test, report, assemble, release Small core expandable with plugins Project Object Model (POM) Convention over configuration Dependency management Common lifecycle
  • 3. 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>
  • 4. Same in Maven pom.xml <project> <modelVersion>4.0.0</modelVersion> <groupId>com.liferay.sample</groupId> <artifactId>my-project</artifactId> <version>1.0-SNAPSHOT</version> </project>
  • 5. The Project Object Model Analogous to Makefile or build.xml Versioned <major>.<minor>.<incremental>-<qualifier> Packaging (pom, jar, war, ejb, ear, etc.) Inheritance Multi-module Dependencies Profiles Properties
  • 6. Dependency Management Declarative Transitive Identified by: groupId, artifactId, version and type combination Scoped: compile, provided, runtime, test or system Coping with 3rd party dependencies
  • 8. Build Lifecycle Three standard lifecycles: clean, default and site Lifecycles have phases Goals are attached to phases Lifecycle phases differs based on package type Common goals: process-resources, compile process-test-resources, test-compile, test install, deploy
  • 9. Repositories Place where all artifacts are stored Local Locate in USER_HOME/.m2/repository Cached copy of remote downloads May contain project locally built artifacts Remote Central (repo1.maven.org), internal or external Proxy or Cache
  • 10. 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-SNAPSHOT -DgroupId=com.liferay.sample -DartifactId=sample-portlet -Dversion=1.0-SNAPSHOT -DinteractiveMode=false
  • 11. Liferay and Maven Goal is to make maven a first class citizen in Liferay plugin development (alternative to ant based sdk) No Liferay core will not be built with maven, for now :-) Inspired by a community members effort in 5.2.3 (Milen Dyankov) Mostly developed by Me and Thiago Moreira with community feedback and patches
  • 12. Current state CE artifacts published to Central through Sonatypes repository Artifacts: portal-client, portal-impl, portal-service, portal- web, tunnel-web, util-bridges, util-java and util-taglib Artifacts include javadoc and source archives Archetypes for hook, ext, layouttpl, portlet, servicebuilder, theme and web
  • 13. Current state Plugins: ExtBuilder, LangBuilder, PluginDeployer, PluginDirectDeployer, ServiceBuilder, ThemeMerger, ThumbnailBuilder and WSDDBuilder All plugins package in one maven plugin package liferay-maven-plugin Maven 2.2.x compatible Some issues with Maven 3.0.x
  • 14. Liferay EE and Maven Problematic because EE artifacts are not published to public repositories Building EE artifacts from source also not possible because EE source does not have build scripts Solution: Provide prebuilt package with install script to install them in either local repository or internal remote repository like Sonatype Nexus
  • 15. Installing artifacts locally In Liferay portal source (not needed once released) ant -f build-maven.xml zip-maven Unzip liferay-portal-maven-<version>.zip Install artifacts by running ant install Deploy to repository (optional) Edit lp.maven.repository.url in build.properties Run ant deploy
  • 16. Creating a portlet mvn archetype:generate -DarchetypeArtifactId=liferay-portlet-archetype -DarchetypeGroupId=com.liferay.maven.archetypes -DarchetypeVersion=6.1.0-SNAPSHOT -DarchetypeCatalog=local,remote -DartifactId=sample-portlet -DgroupId=com.liferay.sample -Dversion=1.0-SNAPSHOT
  • 17. Maven Best Practices Setup internal repository and maven proxy Reduces build time by caching dependencies Increases build stability and repeatability Allows enforcing rules regarding allowed libraries Never use 3rd party SNAPHOT dependencies Declare your dependencies and don’t rely on transitive dependencies for libraries that you need
  • 18. Resources Maven: The Complete Reference http://www.sonatype.com/books/mvnref-book/reference/ Maven by Example http://www.sonatype.com/books/mvnex-book/reference/ Maven homepage http://maven.apache.org My maven incubator - bleeding edge and some extras https://github.com/mikakoivisto/liferay-maven-incubation
  • 19. Credits Figures from Maven: The Complete Reference by Sonatype, Inc. http://www.sonatype.com/books/mvnref-book/reference/