SlideShare a Scribd company logo
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!

More Related Content

What's hot

What's hot (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
 

Viewers also liked

Viewers also liked (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
 

Similar to Liferay maven sdk

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
Renato Primavera
 
Maven with Flex
Maven with FlexMaven with Flex
Maven with Flex
Priyank
 

Similar to 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
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 

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/