SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
Apache Maven @ eXo Platform
    Hanoï – 09 Feb 2010


                                Arnaud Héritier
                                  eXo Platform
                      Software Factory Manager
Apache Maven
OVERVIEW



   Licensed under a Creative Commons license
Apache Maven
BASICS



   Licensed under a Creative Commons license   3
Definition
●    Apache Maven is a software project management
     and comprehension tool.
●    Based on the concept of a project object model
     (POM), Maven can manage a project's build,
     binaries, reporting and documentation from a
     central piece of information.
●    Apache Maven is a command line tool with some
     IDE integrations.




       Licensed under a Creative Commons license
Conventions
●    1 project = 1 artifact (pom, jar, war, ear, …)

●    Standardized
     -  directories layout
     -  project descriptor (POM)
     -  build lifecycle




          Licensed under a Creative Commons license     5
POM
●    An XML file (pom.xml)                             <?xml version="1.0" encoding="UTF-8"?>!
                                                       <project>!
                                                        <modelVersion>4.0.0</modelVersion>!
                                                        <groupId>org.apache.maven</groupId>!

●    Describing                                         <artifactId>webapp-sample</artifactId>!
                                                        <version>1.1-SNAPSHOT</version>!
     -    Project identification                        <packaging>war</packaging>!
                                                        <name>Simple webapp</name>!
     -    Project version                               <inceptionYear>2007</inceptionYear>!
     -    Project description                           <dependencies>!
                                                         <dependency>!
     -    Build settings                                  <groupId>org.springframework</groupId>!

     -    Dependencies                                    <artifactId>spring-struts</artifactId>!
                                                          <version>2.0.2</version>!
     -    …                                              </dependency>!
                                                         ...!
                                                        </dependencies>!
                                                       </project>!



          Licensed under a Creative Commons license
Dependencies
Without Maven                   With Maven




 Licensed under a Creative Commons license
Dependencies
●    Declaratives
     -  groupId + artifactId + version (+ classifier)
     -  Type (packaging) : jar, war, pom, ear, …

●    Transitives
     -  Lib A needs Lib B
     -  Lib B needs Lib C
     -  Thus Lib A needs Lib C




          Licensed under a Creative Commons license
Dependencies
●    Scope
     -  Compile (by default) : Required to build and run the
        application
     -  Runtime : not required to build the application but
        needed at runtime
            ●    Ex : taglibs
     -    Provided : required to build the application but not
          needed at runtime (provided by the container)
            ●    Ex : Servlet API, Driver SGBD, …
     -    Test : required to build and launch tests but not needed
          by the application itself to build and run
            ●    Ex : Junit, TestNG, DbUnit, …
     -    System : local library with absolute path
            ●    Ex : software products
          Licensed under a Creative Commons license
Dependencies
●    Define all dependencies you are using
     -    and no more !
●    Cleanup your dependencies with
     -    mvn dependency:analyze!
●    Study your dependencies with
     -  mvn dependency:tree!
     -  mvn dependency:list!




          Licensed under a Creative Commons license
Artifact Repository
●    By default :
     -    A central repository
            ●    http://repo1.maven.org/
                 maven2
            ●    Several dozen of Gb of OSS
                 libraries
     -    A local repository
            ●    ${user.home}/.m2/repository
            ●    All artifacts
                  -    Used by maven and its
                       plugins
                  -    Used by your projects
                       (dependencies)
                  -    Produced by your projects



          Licensed under a Creative Commons license
Artifact Repository
                                            ●    By default Maven
                                                 downloads artifacts
                                                 required by the project or
                                                 itself from central
                                            ●    Downloaded artifacts are
                                                 stored in the local
                                                 repository




Licensed under a Creative Commons license
Versions
●    Project and dependency versions
●    Two different version variants
          SNAPSHOT version
            ●    The version number ends with –SNAPSHOT
            ●    The project is in development
            ●    Deliveries are changing over the time and are overridden
                 after each build
            ●    Artifacts are deployed with a timestamp on remote
                 repositories
          RELEASE version
            ●    The version number doesn’t end with –SNAPSHOT
            ●    Binaries won’t change
          Licensed under a Creative Commons license
Versions




Licensed under a Creative Commons license
Versions
●    About SNAPSHOT dependencies
     -    Maven allows the configuration of an update policy.
          The update policy defines the recurrence of checks if
          there is a new SNAPSHOT version available on the
          remote repository :
            ●    always
            ●    daily (by default)
            ●    interval:X (a given period in minutes)
            ●    never
     -    Must not be used in a released project
            ●    They can change thus the release also 
            ●    The release plugin will enforce it 

          Licensed under a Creative Commons license
Versions
●    Use the versions plugin to update all versions in all
     POMs
     -    mvn versions:set 

          –DnewVersion=A.B.C-SNAPSHOT!




          Licensed under a Creative Commons license
Profiles
●    Allow to modify the default behavior of Maven by
     overriding/adding some settings
●    Use mvn help:active-profiles to debug
●    Explicit activation or deactivation
mvn <phases or goals> !
     -PprofileId1,-profileId2 !
     -P!profileId3!




       Licensed under a Creative Commons license
Profiles
●    activeByDefault = If no other profile is activated
●    Activation through Maven settings
<settings>!
  ...!
  <activeProfiles>!
    <activeProfile>profile-1</activeProfile>!
  </activeProfiles>!
  ...!
</settings>!




       Licensed under a Creative Commons license
Profiles
●    Activation based on environment variables
<profiles>!                                         <profiles>!

     <profile>!                                       <profile>!

       <activation>!                                    <activation>!

         <property>!                                      <property>!
                                                               <name>!skip-enforce</name>!
              <name>run-its</name>!
                                                          </property>!
              <value>true</value>!
                                                        </activation>!
         </property>!
                                                        ...!
       </activation>!
                                                      </profile>!
       ...!
                                                    </profiles>!
     </profile>!
</profiles>!


        Licensed under a Creative Commons license
Profiles
●    OS / Java settings
<profiles>!                                         <profiles>!
                                                      <profile>!
     <profile>!
                                                        <activation>!
       <activation>!
                                                             <os>!
         <jdk>[1.3,1.6)</jdk>!
                                                             <name>Windows XP</name>!
       </activation>!
                                                             <family>Windows</family>!
       ...!
                                                             <arch>x86</arch>!
     </profile>!
                                                             <version>5.1.2600</version>!
</profiles>!
                                                        </os>!
                                                      </activation>!
                                                      ...!
                                                      </profile>!
                                                    </profiles>!
        Licensed under a Creative Commons license
Profiles
●    Activation on present or missing files
<profiles>!
     <profile>!
       <activation>!
         <file>!
           <missing>${project.build.directory}/generated-sources/
     axistools/wsdl2java/org/apache/maven</missing>!
         </file>!
       </activation>!
       ...!
     </profile>!
</profiles>!


        Licensed under a Creative Commons license
Reactor
●    Ability of Maven to build                        pom.xml :
     several sub-modules                              <modules>
     resolving the order of their                      <module>moduleA</module>
     dependencies                                      <module>moduleC</module>

●    Modules have to be                                <module>moduleB</module>
     defined in the POM                               </modules>

     -    For a performance reasons




          Licensed under a Creative Commons license
Inheritence
●    Share settings between
     projects/modules
●    Project
     -    Business1
             ●    Jar
             ●    War
     -    Business2
             ●    Jar                                 pom.xml for module Jar1
             ●    War                                 <parent>

●    By default the parent                              <groupId>X.Y.Z</groupId>
     project is supposed to be                          <artifactId>jars</artifactId>
     in the parent directory                            <version>1.0-SNAPSHOT<version>
     (../)                                            </parent>

          Licensed under a Creative Commons license
Build Lifecycle And Plugins
                                            ●    Plugin based architecture
                                                 for a great extensibility
                                            ●    Standardized lifecycle to
                                                 build all types of
                                                 archetypes




Licensed under a Creative Commons license
Apache Maven
GOOD & BAD PRACTICES



   Licensed under a Creative Commons license
Apache Maven
KISS



   Licensed under a Creative Commons license
K.I.S.S.
●    Keep It Simple, Stupid
●    Start from scratch
     -    Do not copy/paste what you find without understanding
●    Use only what you need
     -    It’s not because maven offers many features that you
          need to use them
            ●    Filtering
            ●    Modules
            ●    Profiles
            ●    …


          Licensed under a Creative Commons license
Apache Maven
PROJECT ORGANIZATION
GOOD & BAD PRACTICES


   Licensed under a Creative Commons license
Project bad practices
●    Ignore Maven conventions
     -  Except if your are migrating from something else and
        the target has to be to follow them.
     -  Except if they are not compatible with your IDE
●    Different versions in sub-modules
     -    In that case they are standalone projects.
●    Too many inheritance levels
     -    It makes the POMs maintenance more complex
                  -    Where should I set this plugin parameter ? In which parent ?




          Licensed under a Creative Commons license
Project bad practices
●    Have too many modules
     -    Is there a good reason ?
            ●    Technical constraint ?
            ●    Team organization ?
     -    It increases the build time
            ●    Many more artifacts to generate
            ●    Dependencies resolution more complex
     -    It involves more complex developments
            ●    More modules to import in your IDE
            ●    More modules to update …



          Licensed under a Creative Commons license
Project good practices
●    Use the default
     inheritance :
     -    The reactor project is also
          the parent of its modules.
     -    Configuration is easier :
             ●    No need to redefine SCM
                  settings, site distribution
                  settings …




          Licensed under a Creative Commons license
Apache Maven
POM GOOD & BAD PRACTICES



   Licensed under a Creative Commons license
POM bad practices
●    Dependencies :
     -    DON’T confuse dependencies and
          dependencyManagement
●    Plugins :
     -  DON’T confuse plugins and pluginManagement
     -  DON’T use AntRun plugin everywhere
     -  DON’T let Maven choose plugins versions for you




          Licensed under a Creative Commons license
POM bad practices
●    Profiles :
     -  DON’T create environment dependant builds
     -  DON’T rely on dependencies coming from profiles
        (there is no transitive activation of profiles)
●    Reporting and quality
     -  DON’T activate on an existing project all reports with
        default configuration
     -  DON’T control formatting rules without giving settings
        for IDEs.
●    DON’T put everything you find in your POM.


          Licensed under a Creative Commons license
POM good practices
●    Set versions of dependencies in project parent’s
     dependencyManagement
●    Set dependencies (groupId, artifactId, scope) in
     each module they are used
●    Use the dependency plugin (from apache) and
     versions plugin (from mojo) to analyze, cleanup
     and update your dependencies.




       Licensed under a Creative Commons license
Apache Maven
DEVELOPMENT
GOOD & BAD PRACTICES


   Licensed under a Creative Commons license
Development bad practices
●    DON’T spend your time in the terminal,
●    DON’T exchange libraries through emails,
●    DON’T always use "-Dmaven.test.skip=true”
●    DON’T manually do releases




       Licensed under a Creative Commons license
Development good practices
●    Keep up-to-date your version of Maven
     -    For example in 2.1 the time of dependencies/modules
          resolution decreased a lot (Initialization of a project of
          150 modules passed from 8 minutes to less than 1)
●    Use the reactor plugin (Maven < 2.1) or native
     reactor command line options (Maven >= 2.1) to
     rebuild only a subpart of your project :
     -  All modules depending on module XXX
     -  All modules used to build XXX
●    Try to not use Maven features not supported by
     your IDE (resources filtering with the plugin
     eclipse:eclipse)
          Licensed under a Creative Commons license
Apache Maven
TO GO FURTHER …



   Licensed under a Creative Commons license
Apache Maven
DOCUMENTATIONS



   Licensed under a Creative Commons license
Some links
●    The main web site :
     -    http://maven.apache.org
●    Project’s team wiki :
     -    http://docs.codehaus.org/display/MAVEN
●    Project’s users wiki :
     -    http://docs.codehaus.org/display/MAVENUSER




          Licensed under a Creative Commons license
Books
●    Sonatype / O’Reilly :
     -    The Definitive Guide
     -    http://www.sonatype.com/
          books
     -    Free download
     -    Available in several
          languages
            ●    Soon in French




          Licensed under a Creative Commons license
Books
●    Exist Global
     -    Better builds with Maven
     -    http://www.maestrodev.com/
          better-build-maven
     -    Free download




          Licensed under a Creative Commons license
Books
●    Nicolas De loof
     Arnaud Héritier
     -    Published by Pearson
     -    Collection Référence
     -    Based on our own
          experiences with Maven.
          From beginners to experts.
     -    In French only
     -    Available on 20th November




          Licensed under a Creative Commons license
Apache Maven
QUESTIONS ?



   Licensed under a Creative Commons license
Licence et copyrights
●    Photos and logos belong to their respective
     authors/owners
●    Content under Creative Commons 3.0
     -    Attribution — You must attribute the work in the manner specified by the
          author or licensor (but not in any way that suggests that they endorse you or
          your use of the work).
     -    Noncommercial — You may not use this work for commercial
          purposes.
     -    Share Alike — If you alter, transform, or build upon this work, you may
          distribute the resulting work only under the same or similar license to this one.
●    http://creativecommons.org/licenses/by-nc-sa/3.0/us/


          Licensed under a Creative Commons license

Contenu connexe

Tendances

Version Management in Maven
Version Management in MavenVersion Management in Maven
Version Management in Maven
Geert Pante
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
Alan Parkinson
 

Tendances (20)

Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Version Management in Maven
Version Management in MavenVersion Management in Maven
Version Management in Maven
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT Academy
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Introduction to maven
Introduction to mavenIntroduction to maven
Introduction to maven
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
 
Maven
MavenMaven
Maven
 
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
Apache MavenApache Maven
Apache Maven
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
Maven
MavenMaven
Maven
 
Agile Software Development & Tools
Agile Software Development & ToolsAgile Software Development & Tools
Agile Software Development & Tools
 
Maven Overview
Maven OverviewMaven Overview
Maven 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
 
Apache Maven 2 Part 2
Apache Maven 2 Part 2Apache Maven 2 Part 2
Apache Maven 2 Part 2
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yards
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 

En vedette

En vedette (11)

Hands on iOS developments with jenkins
Hands on iOS developments with jenkinsHands on iOS developments with jenkins
Hands on iOS developments with jenkins
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
2014 August - eXo Software Factory Overview
2014 August - eXo Software Factory Overview2014 August - eXo Software Factory Overview
2014 August - eXo Software Factory Overview
 
CRaSH @ JUGSummerCamp 2012 - Quickie
CRaSH @ JUGSummerCamp 2012 - QuickieCRaSH @ JUGSummerCamp 2012 - Quickie
CRaSH @ JUGSummerCamp 2012 - Quickie
 
Java is evolving rapidly: Maven helps you staying on track
Java is evolving rapidly:  Maven helps you staying on trackJava is evolving rapidly:  Maven helps you staying on track
Java is evolving rapidly: Maven helps you staying on track
 
LavaJUG-Maven 3.x, will it lives up to its promises
LavaJUG-Maven 3.x, will it lives up to its promisesLavaJUG-Maven 3.x, will it lives up to its promises
LavaJUG-Maven 3.x, will it lives up to its promises
 
Sonar In Action 20110302-vn
Sonar In Action 20110302-vnSonar In Action 20110302-vn
Sonar In Action 20110302-vn
 
Quand java prend de la vitesse, apache maven vous garde sur les rails
Quand java prend de la vitesse, apache maven vous garde sur les railsQuand java prend de la vitesse, apache maven vous garde sur les rails
Quand java prend de la vitesse, apache maven vous garde sur les rails
 
Devops Recto-Verso @ DevoxxMA
Devops Recto-Verso @ DevoxxMADevops Recto-Verso @ DevoxxMA
Devops Recto-Verso @ DevoxxMA
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Continuous delivery-with-maven
Continuous delivery-with-mavenContinuous delivery-with-maven
Continuous delivery-with-maven
 

Similaire à Maven for eXo VN

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
 

Similaire à Maven for eXo VN (20)

Apache Maven at GenevaJUG by Arnaud Héritier
Apache Maven at GenevaJUG by Arnaud HéritierApache Maven at GenevaJUG by Arnaud Héritier
Apache Maven at GenevaJUG by Arnaud Héritier
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
 
Maven
MavenMaven
Maven
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Java Build Tools
Java Build ToolsJava Build Tools
Java Build Tools
 
Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOps
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
 
Session 2
Session 2Session 2
Session 2
 
Session 2
Session 2Session 2
Session 2
 
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
 
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
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 

Plus de Arnaud Héritier

Plus de Arnaud Héritier (16)

eXo Software Factory Overview
eXo Software Factory OvervieweXo Software Factory Overview
eXo Software Factory Overview
 
Mobile developments at eXo
Mobile developments at eXoMobile developments at eXo
Mobile developments at eXo
 
Jenkins User Meetup - eXo usages of Jenkins
Jenkins User Meetup - eXo usages of JenkinsJenkins User Meetup - eXo usages of Jenkins
Jenkins User Meetup - eXo usages of Jenkins
 
ToursJUG-Maven 3.x, will it lives up to its promises
ToursJUG-Maven 3.x, will it lives up to its promisesToursJUG-Maven 3.x, will it lives up to its promises
ToursJUG-Maven 3.x, will it lives up to its promises
 
YaJUG-Maven 3.x, will it lives up to its promises
YaJUG-Maven 3.x, will it lives up to its promisesYaJUG-Maven 3.x, will it lives up to its promises
YaJUG-Maven 3.x, will it lives up to its promises
 
BordeauxJUG-Maven 3.x, will it lives up to its promises
BordeauxJUG-Maven 3.x, will it lives up to its promisesBordeauxJUG-Maven 3.x, will it lives up to its promises
BordeauxJUG-Maven 3.x, will it lives up to its promises
 
ToulouseJUG-Maven 3.x, will it lives up to its promises
ToulouseJUG-Maven 3.x, will it lives up to its promisesToulouseJUG-Maven 3.x, will it lives up to its promises
ToulouseJUG-Maven 3.x, will it lives up to its promises
 
Apache Maven - eXo VN office presentation
Apache Maven - eXo VN office presentationApache Maven - eXo VN office presentation
Apache Maven - eXo VN office presentation
 
LyonJUG - Maven 3.x, will it live up to its promises?
LyonJUG - Maven 3.x, will it live up to its promises?LyonJUG - Maven 3.x, will it live up to its promises?
LyonJUG - Maven 3.x, will it live up to its promises?
 
20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache Maven20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache Maven
 
20080311 - Paris Vi Master STL TA - Initiation Maven
20080311 - Paris Vi Master STL TA - Initiation Maven20080311 - Paris Vi Master STL TA - Initiation Maven
20080311 - Paris Vi Master STL TA - Initiation Maven
 
20081008 - Tours Jug - Apache Maven
20081008  - Tours Jug - Apache Maven20081008  - Tours Jug - Apache Maven
20081008 - Tours Jug - Apache Maven
 
20081023 - Paris Vi Master STL TA - Initiation Maven
20081023 - Paris Vi Master STL TA - Initiation Maven20081023 - Paris Vi Master STL TA - Initiation Maven
20081023 - Paris Vi Master STL TA - Initiation Maven
 
20080513 - Paris Jug - Maven à La Demande
20080513 - Paris Jug - Maven à La Demande20080513 - Paris Jug - Maven à La Demande
20080513 - Paris Jug - Maven à La Demande
 
20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache Maven20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache Maven
 
20091020 - Normandy Jug - Builders Battle
20091020 - Normandy Jug - Builders Battle20091020 - Normandy Jug - Builders Battle
20091020 - Normandy Jug - Builders Battle
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
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...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
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)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Maven for eXo VN

  • 1. Apache Maven @ eXo Platform Hanoï – 09 Feb 2010 Arnaud Héritier eXo Platform Software Factory Manager
  • 2. Apache Maven OVERVIEW Licensed under a Creative Commons license
  • 3. Apache Maven BASICS Licensed under a Creative Commons license 3
  • 4. Definition ●  Apache Maven is a software project management and comprehension tool. ●  Based on the concept of a project object model (POM), Maven can manage a project's build, binaries, reporting and documentation from a central piece of information. ●  Apache Maven is a command line tool with some IDE integrations. Licensed under a Creative Commons license
  • 5. Conventions ●  1 project = 1 artifact (pom, jar, war, ear, …) ●  Standardized -  directories layout -  project descriptor (POM) -  build lifecycle Licensed under a Creative Commons license 5
  • 6. POM ●  An XML file (pom.xml) <?xml version="1.0" encoding="UTF-8"?>! <project>! <modelVersion>4.0.0</modelVersion>! <groupId>org.apache.maven</groupId>! ●  Describing <artifactId>webapp-sample</artifactId>! <version>1.1-SNAPSHOT</version>! -  Project identification <packaging>war</packaging>! <name>Simple webapp</name>! -  Project version <inceptionYear>2007</inceptionYear>! -  Project description <dependencies>! <dependency>! -  Build settings <groupId>org.springframework</groupId>! -  Dependencies <artifactId>spring-struts</artifactId>! <version>2.0.2</version>! -  … </dependency>! ...! </dependencies>! </project>! Licensed under a Creative Commons license
  • 7. Dependencies Without Maven With Maven Licensed under a Creative Commons license
  • 8. Dependencies ●  Declaratives -  groupId + artifactId + version (+ classifier) -  Type (packaging) : jar, war, pom, ear, … ●  Transitives -  Lib A needs Lib B -  Lib B needs Lib C -  Thus Lib A needs Lib C Licensed under a Creative Commons license
  • 9. Dependencies ●  Scope -  Compile (by default) : Required to build and run the application -  Runtime : not required to build the application but needed at runtime ●  Ex : taglibs -  Provided : required to build the application but not needed at runtime (provided by the container) ●  Ex : Servlet API, Driver SGBD, … -  Test : required to build and launch tests but not needed by the application itself to build and run ●  Ex : Junit, TestNG, DbUnit, … -  System : local library with absolute path ●  Ex : software products Licensed under a Creative Commons license
  • 10. Dependencies ●  Define all dependencies you are using -  and no more ! ●  Cleanup your dependencies with -  mvn dependency:analyze! ●  Study your dependencies with -  mvn dependency:tree! -  mvn dependency:list! Licensed under a Creative Commons license
  • 11. Artifact Repository ●  By default : -  A central repository ●  http://repo1.maven.org/ maven2 ●  Several dozen of Gb of OSS libraries -  A local repository ●  ${user.home}/.m2/repository ●  All artifacts -  Used by maven and its plugins -  Used by your projects (dependencies) -  Produced by your projects Licensed under a Creative Commons license
  • 12. Artifact Repository ●  By default Maven downloads artifacts required by the project or itself from central ●  Downloaded artifacts are stored in the local repository Licensed under a Creative Commons license
  • 13. Versions ●  Project and dependency versions ●  Two different version variants   SNAPSHOT version ●  The version number ends with –SNAPSHOT ●  The project is in development ●  Deliveries are changing over the time and are overridden after each build ●  Artifacts are deployed with a timestamp on remote repositories   RELEASE version ●  The version number doesn’t end with –SNAPSHOT ●  Binaries won’t change Licensed under a Creative Commons license
  • 14. Versions Licensed under a Creative Commons license
  • 15. Versions ●  About SNAPSHOT dependencies -  Maven allows the configuration of an update policy. The update policy defines the recurrence of checks if there is a new SNAPSHOT version available on the remote repository : ●  always ●  daily (by default) ●  interval:X (a given period in minutes) ●  never -  Must not be used in a released project ●  They can change thus the release also  ●  The release plugin will enforce it  Licensed under a Creative Commons license
  • 16. Versions ●  Use the versions plugin to update all versions in all POMs -  mvn versions:set 
 –DnewVersion=A.B.C-SNAPSHOT! Licensed under a Creative Commons license
  • 17. Profiles ●  Allow to modify the default behavior of Maven by overriding/adding some settings ●  Use mvn help:active-profiles to debug ●  Explicit activation or deactivation mvn <phases or goals> ! -PprofileId1,-profileId2 ! -P!profileId3! Licensed under a Creative Commons license
  • 18. Profiles ●  activeByDefault = If no other profile is activated ●  Activation through Maven settings <settings>! ...! <activeProfiles>! <activeProfile>profile-1</activeProfile>! </activeProfiles>! ...! </settings>! Licensed under a Creative Commons license
  • 19. Profiles ●  Activation based on environment variables <profiles>! <profiles>! <profile>! <profile>! <activation>! <activation>! <property>! <property>! <name>!skip-enforce</name>! <name>run-its</name>! </property>! <value>true</value>! </activation>! </property>! ...! </activation>! </profile>! ...! </profiles>! </profile>! </profiles>! Licensed under a Creative Commons license
  • 20. Profiles ●  OS / Java settings <profiles>! <profiles>! <profile>! <profile>! <activation>! <activation>! <os>! <jdk>[1.3,1.6)</jdk>! <name>Windows XP</name>! </activation>! <family>Windows</family>! ...! <arch>x86</arch>! </profile>! <version>5.1.2600</version>! </profiles>! </os>! </activation>! ...! </profile>! </profiles>! Licensed under a Creative Commons license
  • 21. Profiles ●  Activation on present or missing files <profiles>! <profile>! <activation>! <file>! <missing>${project.build.directory}/generated-sources/ axistools/wsdl2java/org/apache/maven</missing>! </file>! </activation>! ...! </profile>! </profiles>! Licensed under a Creative Commons license
  • 22. Reactor ●  Ability of Maven to build pom.xml : several sub-modules <modules> resolving the order of their <module>moduleA</module> dependencies <module>moduleC</module> ●  Modules have to be <module>moduleB</module> defined in the POM </modules> -  For a performance reasons Licensed under a Creative Commons license
  • 23. Inheritence ●  Share settings between projects/modules ●  Project -  Business1 ●  Jar ●  War -  Business2 ●  Jar pom.xml for module Jar1 ●  War <parent> ●  By default the parent <groupId>X.Y.Z</groupId> project is supposed to be <artifactId>jars</artifactId> in the parent directory <version>1.0-SNAPSHOT<version> (../) </parent> Licensed under a Creative Commons license
  • 24. Build Lifecycle And Plugins ●  Plugin based architecture for a great extensibility ●  Standardized lifecycle to build all types of archetypes Licensed under a Creative Commons license
  • 25. Apache Maven GOOD & BAD PRACTICES Licensed under a Creative Commons license
  • 26. Apache Maven KISS Licensed under a Creative Commons license
  • 27. K.I.S.S. ●  Keep It Simple, Stupid ●  Start from scratch -  Do not copy/paste what you find without understanding ●  Use only what you need -  It’s not because maven offers many features that you need to use them ●  Filtering ●  Modules ●  Profiles ●  … Licensed under a Creative Commons license
  • 28. Apache Maven PROJECT ORGANIZATION GOOD & BAD PRACTICES Licensed under a Creative Commons license
  • 29. Project bad practices ●  Ignore Maven conventions -  Except if your are migrating from something else and the target has to be to follow them. -  Except if they are not compatible with your IDE ●  Different versions in sub-modules -  In that case they are standalone projects. ●  Too many inheritance levels -  It makes the POMs maintenance more complex -  Where should I set this plugin parameter ? In which parent ? Licensed under a Creative Commons license
  • 30. Project bad practices ●  Have too many modules -  Is there a good reason ? ●  Technical constraint ? ●  Team organization ? -  It increases the build time ●  Many more artifacts to generate ●  Dependencies resolution more complex -  It involves more complex developments ●  More modules to import in your IDE ●  More modules to update … Licensed under a Creative Commons license
  • 31. Project good practices ●  Use the default inheritance : -  The reactor project is also the parent of its modules. -  Configuration is easier : ●  No need to redefine SCM settings, site distribution settings … Licensed under a Creative Commons license
  • 32. Apache Maven POM GOOD & BAD PRACTICES Licensed under a Creative Commons license
  • 33. POM bad practices ●  Dependencies : -  DON’T confuse dependencies and dependencyManagement ●  Plugins : -  DON’T confuse plugins and pluginManagement -  DON’T use AntRun plugin everywhere -  DON’T let Maven choose plugins versions for you Licensed under a Creative Commons license
  • 34. POM bad practices ●  Profiles : -  DON’T create environment dependant builds -  DON’T rely on dependencies coming from profiles (there is no transitive activation of profiles) ●  Reporting and quality -  DON’T activate on an existing project all reports with default configuration -  DON’T control formatting rules without giving settings for IDEs. ●  DON’T put everything you find in your POM. Licensed under a Creative Commons license
  • 35. POM good practices ●  Set versions of dependencies in project parent’s dependencyManagement ●  Set dependencies (groupId, artifactId, scope) in each module they are used ●  Use the dependency plugin (from apache) and versions plugin (from mojo) to analyze, cleanup and update your dependencies. Licensed under a Creative Commons license
  • 36. Apache Maven DEVELOPMENT GOOD & BAD PRACTICES Licensed under a Creative Commons license
  • 37. Development bad practices ●  DON’T spend your time in the terminal, ●  DON’T exchange libraries through emails, ●  DON’T always use "-Dmaven.test.skip=true” ●  DON’T manually do releases Licensed under a Creative Commons license
  • 38. Development good practices ●  Keep up-to-date your version of Maven -  For example in 2.1 the time of dependencies/modules resolution decreased a lot (Initialization of a project of 150 modules passed from 8 minutes to less than 1) ●  Use the reactor plugin (Maven < 2.1) or native reactor command line options (Maven >= 2.1) to rebuild only a subpart of your project : -  All modules depending on module XXX -  All modules used to build XXX ●  Try to not use Maven features not supported by your IDE (resources filtering with the plugin eclipse:eclipse) Licensed under a Creative Commons license
  • 39. Apache Maven TO GO FURTHER … Licensed under a Creative Commons license
  • 40. Apache Maven DOCUMENTATIONS Licensed under a Creative Commons license
  • 41. Some links ●  The main web site : -  http://maven.apache.org ●  Project’s team wiki : -  http://docs.codehaus.org/display/MAVEN ●  Project’s users wiki : -  http://docs.codehaus.org/display/MAVENUSER Licensed under a Creative Commons license
  • 42. Books ●  Sonatype / O’Reilly : -  The Definitive Guide -  http://www.sonatype.com/ books -  Free download -  Available in several languages ●  Soon in French Licensed under a Creative Commons license
  • 43. Books ●  Exist Global -  Better builds with Maven -  http://www.maestrodev.com/ better-build-maven -  Free download Licensed under a Creative Commons license
  • 44. Books ●  Nicolas De loof Arnaud Héritier -  Published by Pearson -  Collection Référence -  Based on our own experiences with Maven. From beginners to experts. -  In French only -  Available on 20th November Licensed under a Creative Commons license
  • 45. Apache Maven QUESTIONS ? Licensed under a Creative Commons license
  • 46. Licence et copyrights ●  Photos and logos belong to their respective authors/owners ●  Content under Creative Commons 3.0 -  Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). -  Noncommercial — You may not use this work for commercial purposes. -  Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. ●  http://creativecommons.org/licenses/by-nc-sa/3.0/us/ Licensed under a Creative Commons license