SlideShare una empresa de Scribd logo
1 de 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!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Destacado

Destacado (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 a 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 a 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
 

Último

Último (20)

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...
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
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
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
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
 
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, ...
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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/