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 (19)

PPT
Maven Introduction
Sandeep Chawla
 
PPTX
Maven Basics - Explained
Smita Prasad
 
PPTX
Maven for Dummies
Tomer Gabel
 
PDF
Apache Maven In 10 Slides
Robert Burrell Donkin
 
PPTX
Maven tutorial
Dragos Balan
 
PDF
Hands On with Maven
Sid Anand
 
PPTX
Introduction to Maven
Onkar Deshpande
 
PDF
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
PPTX
Learning Maven by Example
Hsi-Kai Wang
 
PPTX
Maven
feng lee
 
PDF
Maven tutorial
James Cellini
 
PPTX
Maven
Chris Roeder
 
PPTX
Introduction to Maven
Mindfire Solutions
 
PPTX
An introduction to Maven
Joao Pereira
 
PPTX
Apache maven 2 overview
Return on Intelligence
 
PPTX
Maven plugins, properties en profiles: Advanced concepts in Maven
Geert Pante
 
PPT
Using Maven 2
andyhot
 
PDF
Java Builds with Maven and Ant
David Noble
 
Maven Introduction
Sandeep Chawla
 
Maven Basics - Explained
Smita Prasad
 
Maven for Dummies
Tomer Gabel
 
Apache Maven In 10 Slides
Robert Burrell Donkin
 
Maven tutorial
Dragos Balan
 
Hands On with Maven
Sid Anand
 
Introduction to Maven
Onkar Deshpande
 
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
Learning Maven by Example
Hsi-Kai Wang
 
Maven
feng lee
 
Maven tutorial
James Cellini
 
Introduction to Maven
Mindfire Solutions
 
An introduction to Maven
Joao Pereira
 
Apache maven 2 overview
Return on Intelligence
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Geert Pante
 
Using Maven 2
andyhot
 
Java Builds with Maven and Ant
David Noble
 

Viewers also liked (6)

PPTX
Portlet Framework: the Liferay way
riround
 
PDF
Portets to composite applications
Serge Huber
 
PPT
Portal Presention
JayaPrakash.m
 
PDF
EclipseCon Europe 2015 - liferay modularity patterns using OSGi -Rafik Harabi
Rafik HARABI
 
PPT
Liferay Developer Best Practices for a Successful Deployment
rivetlogic
 
PDF
Introduction to Portlets Using Liferay Portal
rivetlogic
 
Portlet Framework: the Liferay way
riround
 
Portets to composite applications
Serge Huber
 
Portal Presention
JayaPrakash.m
 
EclipseCon Europe 2015 - liferay modularity patterns using OSGi -Rafik Harabi
Rafik HARABI
 
Liferay Developer Best Practices for a Successful Deployment
rivetlogic
 
Introduction to Portlets Using Liferay Portal
rivetlogic
 
Ad

Similar to Liferay maven sdk (20)

PDF
Mavenizing your Liferay project
mimacom
 
PPTX
Maven
Emprovise
 
PDF
Build Automation using Maven
Ankit Gubrani
 
PPTX
(Re)-Introduction to Maven
Eric Wyles
 
PDF
Fundamental of apache maven
Rajesh Kumar
 
PDF
Apache maven
Shreyas Lokkur
 
PPT
Introduction tomaven
Manav Prasad
 
PPTX
Maven basics
Vijay Krishnan Ramaswamy
 
PPTX
Introduction to Maven for beginners and DevOps
SISTechnologies
 
PDF
Introduction to maven, its configuration, lifecycle and relationship to JS world
Dmitry Bakaleinik
 
PPTX
How to push to production a project with 100+ plugins in less than 10 minutes
Thiago Leão Moreira
 
ODP
An Introduction to Maven Part 1
MD Sayem Ahmed
 
ODP
Maven in Java EE project
Ondrej Mihályi
 
PPTX
How maven makes your development group look like a bunch of professionals.
Fazreil Amreen Abdul Jalil
 
PDF
01/2009 - Portral development with liferay
daveayan
 
PPTX
Maven
Nishant Arora
 
PPTX
Maven
Shraddha
 
PPT
Maven 2 features
Angel Ruiz
 
Mavenizing your Liferay project
mimacom
 
Maven
Emprovise
 
Build Automation using Maven
Ankit Gubrani
 
(Re)-Introduction to Maven
Eric Wyles
 
Fundamental of apache maven
Rajesh Kumar
 
Apache maven
Shreyas Lokkur
 
Introduction tomaven
Manav Prasad
 
Introduction to Maven for beginners and DevOps
SISTechnologies
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Dmitry Bakaleinik
 
How to push to production a project with 100+ plugins in less than 10 minutes
Thiago Leão Moreira
 
An Introduction to Maven Part 1
MD Sayem Ahmed
 
Maven in Java EE project
Ondrej Mihályi
 
How maven makes your development group look like a bunch of professionals.
Fazreil Amreen Abdul Jalil
 
01/2009 - Portral development with liferay
daveayan
 
Maven
Shraddha
 
Maven 2 features
Angel Ruiz
 
Ad

Recently uploaded (20)

PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 

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/