SlideShare una empresa de Scribd logo
1 de 129
Descargar para leer sin conexión
Everything about …
APACHE MAVEN
Arnaud Héritier
                  •    eXo - Software Factory Manager
                        »  In charge of tools and methods
                  •    Apache Maven :
                        »  Committer since 2004 and member of the
                          Project Management Committee

                  •    Coauthor of « Apache Maven »
                        »  published by Pearson (in French)
                  •    Contact me :
                        »  http://aheritier.net
                        »  Twitter : @aheritier
                        »  Skype : aheritier



                          2
Apache Maven
OVERVIEW
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 standards/conventions
     driven
     » How many of you are doing JEE and related
       developments ?
                             4
History




•  Initiated in 2001 by Jason Van Zyl in Alexandria,
   an Apache Jakarta project,
•  Moved to Turbine few months after,
•  Became a Top Level Project in 2003.
•  Maven 2.0 released in September 2005
•  Maven 3.0 released in October 2010
     » 3.0.4 – January 2012
                              5
Choose your way of thinking


Conventions approach       Scripting approach




                       6
Competitors

•  Ant + Ivy, Easy Ant, Gant, Gradle, Buildr…
•  Script oriented
    »  You can do what you want !
•  Reuse many of Maven conventions (directories layout,
   …) and services (repositories) but without enforcing
   them
•  The risk for them : Not being able to evolve due to the
   too high level of customization proposed to the user.
    »  We tried on Maven 1 and it died because of that. It was
        impossible to create a set of tests to cover all usages.
     »  It’s like providing a framework without a well tested set of
        public API L


                                    7
With scripts oriented builds
You can have                    But often you have
(if you have good skills)       (moreover after years …)




                            8
With Maven
We dream to deliver       But yesterday we too often had
(Maven 3.x)               (Maven 2.x)




                      9
Apache Maven
CHOOSE YOUR MENU
Your menu

•  Concepts
•  Apache Maven 3.x

•  Good and bad practices

•  Usecases




                       11
Apache Maven
CONCEPTS
Conventions

•  1 project = 1 artifact (pom, jar, war, ear, …)
•  Standardized
     » project descriptor (POM)
     » build lifecycle
     » directories layout
       •  *.java to compile in
          src/[main|test]/java
       •  *.xml, *.properties needed
          in classpath and to bundle
          in archive in src/[main|test]/resources
       •  target directory for generated stuffs (sources, classes, …)
       •  …



                                       13
POM

•    An XML file (pom.xml)       <?xml version="1.0" encoding="UTF-8"?>!
                                 <project>!
                                  <modelVersion>4.0.0</modelVersion>!
                                  <groupId>net.aheritier.samples</groupId>!

•    Describing                   <artifactId>simple-webapp</artifactId>!
                                  <version>1.1-SNAPSHOT</version>!

     » Project identification     <packaging>war</packaging>!
                                  <name>Simple webapp</name>!

     » Project version            <inceptionYear>2007</inceptionYear>!
                                  <dependencies>!

     » Project description         <dependency>!
                                    <groupId>org.springframework</groupId>!

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




                                14
Reactor

•  Split your project in
   sub-modules                 <project>!

•  Maven computes the            ...!


   build order from              <modules>!
                                   <module>moduleA</module>
                                                          !
   dependencies                    <module>moduleB</module>
                                                          !
   between sub-                    <module>moduleC</module>
                                                          !

   modules.                        <module>moduleD</module>
                                                          !
                                   <module>moduleE</module>
                                                          !
•  Modules have to be              <module>moduleF</module>
                                                          !
   defined in the POM            </modules>!

     » No auto-discovery for     ...!


      performance reasons      </project>!




                                   15
Inheritance

                   •  Share settings between
                      projects/modules
                   •  By default the parent
                      project is supposed to
                      be in the parent
                      directory (../)


                    <parent>!
                        <groupId>net.aheritier.sample</groupId>!
                        <artifactId>my-parent</artifactId>!
                        <version>1.0.0-SNAPSHOT<version>!
                    </parent>!




              16
Inheritance


              Use a technical inheritance to organize sub-
              modules
                   Use assembly to package batchs

                   Insert README in all artifacts




                   Use clirr to validate backward
                   compatibility




                   17
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


                                         18
Artifact Repository

                           •  By default Maven
                              downloads artifacts
                              required by the project
                              or itself from central
                           •  Downloaded artifacts
                              are stored in the local
                              repository
                           •  Used to store :
                                » Project’s binaries
                                » Project’s dependencies
                                » Maven and plug-ins
                                 binaries



                      19
Dependencies


Without Maven        With Maven




                20
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



                               21
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




                                           22
Dependencies

•    Define all dependencies you are using
     » and no more !
•    If you have optional dependencies
     » Perhaps you should have optional modules
       instead
•    Cleanup your dependencies with
     » mvn dependency:analyze!
•    Study your dependencies with
     » mvn dependency:tree!
     » mvn dependency:list!

                           23
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



                                  24
Versions




           25
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 L
       •  The release plugin will enforce it J



                                        26
Versions


•    Range
     » From … to …
     » Maven automatically searches for the
       corresponding version (using the update policy
       for released artifacts)
     » To use with caution
       •  Risk of non reproducibility of the build
       •  Risk of side effects on projects depending on yours.




                                     27
Versions

•    Use the versions plugin to update all versions
     of your project and its modules

     mvn versions:set –DnewVersion=A.B.C-SNAPSHOT!




                                28
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!




                                29
Profiles

●    activeByDefault = If no other profile is
     activated
●    Activation through Maven settings
<settings>!
     ...!
     <activeProfiles>!
       <activeProfile>profile-1</activeProfile>!
     </activeProfiles>!
     ...!
</settings>!




                                   30
Profiles

•    Activation based on environment variables
 <profiles>!
                                   <profiles>!
     <profile>!
                                        <profile>!
       <activation>!
                                          <activation>!
         <property>!
                                            <property>!
           <name>run-its</name>!
                                              <name>!skip-enforce</name>!
           <value>true</value>!
                                            </property>!
         </property>!
                                          </activation>!
       </activation>!
                                          ...!
       ...!
                                        </profile>!
     </profile>!
                                   </profiles>!
 </profiles>!


                                   31
Profiles

•    OS / Java settings
                                 <profiles>!
                                      <profile>!
                                        <activation>!
 <profiles>!
                                          <os>!
     <profile>!
                                          <name>Windows XP</name>!
       <activation>!
                                          <family>Windows</family>!
         <jdk>[1.3,1.6)</jdk>!
                                          <arch>x86</arch>!
       </activation>!
                                          <version>5.1.2600</version>!
       ...!
                                        </os>!
     </profile>!
                                      </activation>!
 </profiles>!                         ...!
                                      </profile>!
                                 </profiles>!

                                 32
Profiles

•    Activation on present or missing files
 <profiles>!
     <profile>!
       <activation>!
         <file>!
           <missing>${project.build.directory}/generated-sources/
     axistools/wsdl2java/</missing>!
         </file>!
       </activation>!
       ...!
     </profile>!
 </profiles>!


                                   33
Build Lifecycle And Plugins



                            •  Plugin based
                               architecture for a
                               great extensibility
                            •  Standardized lifecycle
                               to build all types of
                               archetypes




                       34
Build Lifecycle And Plugins
Default Lifecycle         Clean Lifecycle   Site Lifecycle
validate                  pre-clean         pre-site

initialize
                          clean             site
generate-sources          post-clean        post-site

process-sources
                                            site-deploy
generate-resources

process-resources


compile
process-classes

generate-test-sources

process-test-sources

generate-test-resources

process-test-resources

test-compile

process-test-classes


test
prepare-package


package
pre-integration-test

integration-test

post-integration-test

verify


install
deploy

                                       35
Build Lifecycle And Plugins

•    Many plugins
     » Packaging
     » Reporting
     » IDE integration
     » Miscellaneous tools integration
•    Many locations
     » maven.apache.org
     » mojo.codehaus.org
     » code.google.com
     » …
                             Take care while selecting them !!!

                               36
Apache Maven
MAVEN 3.X
Apache Maven 3.x
BACKWARD COMPATIBILITY



                   38
Backward compatibility - Criticisms

•  Migration from Maven 1 to Maven 2 was
   impossible. Everything had to be re-done.
•  Updates between 2.x versions and also
   between 2.0.x weren’t often without side
   effects.




                        39
Backward compatibility

•  Near to 700 integration tests
•  Tested for several months on a large set of
   OSS projects
•  7 alphas + 3 betas versions

•  A bug fix release every 6 weeks

•  It’s a revolution under the hood but an
   evolution for end users




                         40
Maven 3.0.x ITs




                  674




                        41
Apache Maven 3.x
PERFORMANCES



                   42
Performances - Criticisms

•  Maven is slow
•  It spends its time to download the world

•  Whereas everybody has multicore CPUs, it
   doesn’t allow to process modules builds in
   parallel




                        43
Performances

•  A set of benchmark tools was developed to
   measure Maven performances (IO, CPU,
   Memory, Network …)
•  Startup and execution times are reduced
     » Java 5 optimizations
     » Code cleanup and improvements
•  Reduced Memory footprint
•  Artifacts Resolution Caching
     » .lastUpdated files in your local repo
     » Enforce checks with –U option
                              44
Performances – Parallel builds

•    Parallel builds
     » An execution plan is predefined at startup to
       define which modules could be built in //
     » Requires to have up to date plugins to avoid dead
       locks and some others issues
     » Launch a build with 2 threads
       •  mvn –T 2 install
     » Launch a build with 2 threads per CPU core
       •  mvn –T 2C install




                              45
Performances – mvnsh

•    Performances optimizations
     » Intelligent cache system (artifacts resolution,
       project descriptors …)
     » No need to restart a JVM for each build
•    Cross platform « unix like » shell
     » Alias, environment settings …
     » Color highlighting




                                46
Performances – mvnsh

•    All in one
     » Includes Maven 3.x
     » Allows to have color highlighting with “standard”
       Maven 3.x
•    Developed and freely distributed by Sonatype




                             47
Performances – mvnsh




                       48
Apache Maven 3.x
EXTENSIBILITY



                   49
Extensibility - Criticisms

•    It is difficult and time consuming to extend
     maven (write plugins)
     » Many unknown technologies like Plexus for IOC
•    It is difficult/impossible to reuse maven
     plugins
     » Its impossible to extend plugins/mojo and
       lifecycles




                             50
Extensibility

•    New APIs to improve abstraction of
     underneath implementation
     » Aether : to manage artifacts and repositories
•  Plugin classloader partitioning
•  Embeddable

•  IOC replaced by Guice
     » For now (3.0) a wrapper is hiding the change
     » You don’t yet use Guice directly (from plugins for
       example)


                             51
Apache Maven 3.x
ROBUSTNESS



                   52
Robustness - Criticisms

•  Builds aren’t predictable
•  Errors are difficult to diagnose




                          53
Robustness - Validations

•    Many more validations in POMs (warnings or
     errors)
     » Missing plugins versions
     » Duplicated dependencies in a POM
     » Incoherent inheritance (wrong relative path or
       parent not in the upper directory)
•    Improved error messages with links to wiki
     pages for more detailed information




                              54
Robustness – Artifacts management

•    Parent POMs prefer to resolve from
     repositories
     » Version less parent will be available in a future
       maven 3.x release by using the relativePath
       element
•    Profiles usage consolidation
     » No more profiles.xml (incompatible with future
       polyglot feature)




                              55
Robustness – Artifacts management

•  No more support for legacy repository layout
   for Maven 1.0
•  SNAPSHOTs are always deployed with
   timestamps




                        56
Robustness – Plugins management

•    Plugin version is by default RELEASE and no
     more SNAPSHOT
     » Affects command-line invocation
•    Plugins cannot use versions LATEST or
     RELEASE
     » Affects command-line invocation and POM
•    Plugins are resolved only from
     <pluginRepository> entries



                            57
Robustness – Site plugin

•    Site plugin is now completely extracted from
     Maven core
     » It has its own lifecycle
     » reporting section in POM becomes useless
       (moved in plugin configuration)




                             58
Apache Maven 3.x
POM



                   59
Criticisms

•  XML, we don’t like it
•  POM is too verbose

•  POM v4 didn’t evolve last 5 years
     » When will you add new common attributes to
      ease plugins configuration (encoding …)
     » New feature like global exclusions




                             60
POM

•  No change in POM syntax for Maven 3.0
•  Changes will occur in 3.x versions
     » New model with a new version
     » Only new things
     » Generation / deployment of 4.0.0 current POM to
       keep backward compatibility with old maven
       versions
•    Mixins to allow to import POM fragments



                            61
POM - Polyglot

•  Developed and freely distributed by Sonatype
•  Extended version of Maven 3.0 using its new
   embedding and extensibility capabilities
•  Allow translation (read/write) from/to various
   syntaxes
     » Yaml
     » Scala
     » Groovy
•    Allow macros and freeform scripting


                          62
Apache Maven
GOOD & BAD PRACTICES
Apache Maven
KISS



               64
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
       •  …




                               65
Apache Maven
PROJECT ORGANIZATION
GOOD & BAD PRACTICES


               66
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 ?




                                       67
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 …


                                   68
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 …




                         69
Apache Maven
POM GOOD & BAD PRACTICES



               70
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



                            71
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.

                               72
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.




                        73
Apache Maven
DEVELOPMENT
GOOD & BAD PRACTICES


               74
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




                       75
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)


                                 76
Apache Maven
USECASES
Apache Maven
SECURE YOUR CREDENTIALS



               78
Secure your credentials


l        Generate a private key
-     

          arnaud@leopard:~$ mvn --encrypt-master-password toto

          {dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}

          !


●         We save the private key in ~/.m2/settings-security.xml
<settingssecurity>!
          <master>{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}</
          master>!
</settingssecurity>!




                                         79
Secure your credentials
●    You can move this key to another drive ~/.m2/
     settings.xml
-    <settingsSecurity>

       <relocation>/Volumes/ArnaudUsbKey/secure/settings-security.xml</relocation>

     </settingsSecurity>!


●    You create an encrypted version of your server
     password
-    arnaud@mbp-arnaud:~$ mvn --encrypt-password
     titi{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}!



●    You register it in your settings
-    <settings>

       ...

         <servers>

            ...

              <server>

                 <id>mon.server</id>

                 <username>arnaud</username>

                 <password>{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}</password>

              </server>

            ...

         </servers>

       ...

     </settings>!



                                              80
Apache Maven
BUILD A PART OF YOUR PROJECT



               81
Using Reactor Options

•  Options added in maven 2.1
•  Available in 2.0.x with the maven-reactor-
   plugin
     » But syntax is longer
•    Allow to control what you want to build in your
     project




                              82
Using Reactor Options

                 -
                 -     arnaud@mbp-arnaud:~$ mvn install

                                                install
                       [INFO]
                       ------------------------------------------------

                       ------------------------------------------------
                       [INFO] Reactor Summary:
                                      Summary:

                       [INFO]

                       [INFO]
                       [INFO] Project ....................... SUCCESS
                       [2.132s]

                       [2.132s]
                       [INFO] ModuleA ....................... SUCCESS
                       [5.574s]

                       [5.574s]
                       [INFO] ModuleB ....................... SUCCESS
                       [0.455s]

                       [0.455s]
                       [INFO] ModuleC ....................... SUCCESS
                       [0.396s]

                       [0.396s]
                       [INFO] ModuleD ....................... SUCCESS
                       [0.462s]

                       [0.462s]
                       [INFO] ModuleE ....................... SUCCESS
                       [0.723s]

                       [0.723s]
                       [INFO] ModuleF ....................... SUCCESS
                       [0.404s]!
                       [0.404s]




                 l
                 l    Builds everything from A to F



                            83
Using Reactor Options

                 -
                 -     arnaud@mbp-arnaud:~$ mvn install –pl
                       moduleE,moduleB

                       moduleE,moduleB
                               -------------------------------------------

                       [INFO] -------------------------------------------
                                        Summary:

                       [INFO] Reactor Summary:
                       [INFO]

                       [INFO]
                                                                  [2.774s]

                       [INFO] ModuleB .................. SUCCESS [2.774s]
                                                                  [1.008s]

                       [INFO] ModuleE .................. SUCCESS [1.008s]
                       !




                 l
                 l    Builds only modules B and E
                 l
                 l    Following dependencies order
                 l
                 l    -pl --project-list: Build the
                       specified reactor projects instead
                       of all projects


                            84
Using Reactor Options

                 -
                 -     arnaud@mbp-arnaud:~$ mvn install –pl moduleD -am

                               ------------------------------------------

                       [INFO] ------------------------------------------
                                       Summary:

                       [INFO] Reactor Summary:
                       [INFO]

                       [INFO]
                                                                 [4.075s]

                       [INFO] ModuleA ................. SUCCESS [4.075s]
                                                                 [0.468s]

                       [INFO] ModuleB ................. SUCCESS [0.468s]
                                                                 [0.354s]

                       [INFO] ModuleC ................. SUCCESS [0.354s]
                                                                 [0.384s]

                       [INFO] ModuleD ................. SUCCESS [0.384s]
                       !




                 l
                 l    Builds module D (-pl) and all
                       modules it uses as
                       dependencies
                 l
                 l    -am --also-make: If a project list
                       is specified, also make projects
                       that the list depends on
                 l
                 l    Usecase : Build all modules
                       required for a war, ear, …

                            85
Using Reactor Options

                 -
                 -     arnaud@mbp-arnaud:~$ mvn install –pl moduleD -amd

                               ------------------------------------------

                       [INFO] ------------------------------------------
                                       Summary:

                       [INFO] Reactor Summary:
                       [INFO]

                       [INFO]
                                                                 [4.881s]

                       [INFO] ModuleD ................. SUCCESS [4.881s]
                                                                 [0.478s]

                       [INFO] ModuleE ................. SUCCESS [0.478s]
                                                                 [0.427s]

                       [INFO] ModuleF ................. SUCCESS [0.427s]
                       !




                 l
                 l    Builds module D (-pl) and all
                       modules which depend on it
                 l
                 l    -amd --also-make-dependents:
                       If a project list is specified, also
                       make projects that depend on
                       projects on the list
                 l
                 l    Usecase : Check that a change
                       in a module didn’t break others
                       which are using it

                            86
Using Reactor Options

                 -
                 -     arnaud@mbp-arnaud:~$ mvn install –rf moduleD

                               ------------------------------------------

                       [INFO] ------------------------------------------
                                       Summary:

                       [INFO] Reactor Summary:
                       [INFO]

                       [INFO]
                                                                 [9.707s]

                       [INFO] ModuleD ................. SUCCESS [9.707s]
                                                                 [0.625s]

                       [INFO] ModuleE ................. SUCCESS [0.625s]
                       [INFO] ModuleF ................. SUCCESS [0.679s]
                                                                 [2.467s]

                       [INFO] Project ................. SUCCESS [2.467s]
                       !




                 l
                 l    Restarts all the build from
                       module D (-rf)
                 l
                 l     -rf,--resume-from <arg> :
                       Resume reactor from specified
                       project
                 l
                 l    Usecase : The build failed a 1st
                       time in module D, you fixed it,
                       and restart the build were it was
                       to end it.

                            87
Apache Maven
RELEASE YOUR PROJECT



               88
Release of a webapp in 2002

•    Limited usage of eclipse
     » No WTP (Only some features in WSAD),
     » No ability to produce WARs




                           89
Release of a webapp in 2002

•    Many manual tasks
     » Modify settings files
     » Package JARs
     » Copy libraries (external and internal) in a « lib »
       directory
     » Package WAR (often with a zip command)
     » Tag the code (CVS)
     » Send the package on the integration server using
       FTP
     » Deploy the package with AS console


                               90
Release of a webapp in 2002

•    One problem : The are                     •    How long did it take ?
     always problems                                » When everything is
     » Error in config files                          ok : 15 minutes
     »  Missing dependencies                        » When there’s a
     »  Missing file                                  problem : ½ day or
     »  Last minute fix which created a               more
       bug
     »  And many other possibilies ..




                                          91
Maven Release Plugin

•  Automates the release process from tagging
   sources to binaries delivery
•  Release plugin main goals:
     » Prepare : To update maven versions and
       information in POMs and tag the code
     » Perform : To deploy binaries in a maven
       repository
•    After that you can just automate the
     deployment on the AS using cargo for
     example.

                             92
Maven Release Plugin




                       93
Configuration and Prerequisites

•  Project version (must be a SNAPSHOT
   version)
•  Dependencies and plugins versions mustn’t be
   SNAPSHOTs




                       94
Troubleshooting Releases

•    Common errors during release:
     » Build with release profile was tested before and
       fails
     » Local modifications
     » Current version is not a SNAPSHOT
     » SNAPSHOTs in dependencies and/or plugins
     » Missing some configuration (scm, distribMgt, …)
     » Tag already exists
     » Unable to deploy project to the Repository
     » Connection problems
                             95
SCM configuration

SCM binaries have to be in the PATH
SCM credentials have to already be stored or
 you have to pass them in command line with :
 –Dusername=XXX –Dpassword=XXX


<scm>!
 <connection>scm:svn:http://svn.acme.com/myproject/trunk</connection>!
 <developerConnection>scm:svn:https://svn.acme.com/myproject/trunk</developerConnection>!
 <url>http://fisheye.acme.com/browse/myproject/trunk</url>!
</scm>!




                                           96
Distribution Management

•    Where you want to upload released binaries
     » The url of a repository dedicated for your project/
       corporate maven deliveries in your repository
       manager

 <project>!
  <distributionManagement>!
   <repository>!
    <id>repository.acme.com</id>!
    <url>${acme.releases.repo.url}</url>!
                                                            This id will be used in
   </repository>!                                           user’s maven settings
  . . .!                                                    (~/.m2/settings.xml)
  </distributionManagement>!
  . . . !
  <properties>!
   <acme.releases.repo.url>http://repo.acme.com/acme-releases</acme.releases.repo.url>!
   . . .!
  </properties>!
 </project>!                                                Often useful to have a
                                                            property to test the release
                                                            process on a fake
                                                            repository, to validate a
                                                            repo manager ...
                                            97
Repository credentials

•  One server entry is required per different repository id
   in distribution management of projects
•  In a corporate environment, use a unique id for all
   repositories hosted on repository managers using
   same credentials (corporate LDAP …)

 <settings>!
  ...!
  <servers>!
   <server>!
    <id>repository.acme.com</id>!
    <username>aheritier</username>!                     This id is the one defined in
    <password>{ABCDEFGHIJKLMNOPQRSTUVWYZ}</password>
    <password>{ABCDEFGHIJKLMNOPQRSTUVWYZ}</password>!   distributionManagement
   </server>!
   ...!
                                                        entry of the project to
  </servers>!                                           release
  ...!
 </settings>!




                                            98
Default Release Profile in Super POM

•  This profile is used when you generate binaries of
   the release with “mvn release:perform”
•  By default, generates sources and javadocs jars
   for each module.
 <profile>!
  <id>release-profile</id>!
  <activation>!
   <property>!
    <name>performRelease</name>!
    <value>true</value>!                This activation could be
   </property>!
  </activation>!
                                        used in profiles you want to
  <build>!                              activate in the release
   <plugins>!                           process
   ...!
   </plugins>!
  </build>!
                                        Configuration to generate
 </profile>!                            sources and javadoc jars
                                        with basic setting


                                   99
Custom release profile
<project>!
 ...!
 <build>!
  <pluginManagement>!
   <plugins>!
    <plugin>!
      <groupId>org.apache.maven.plugins</groupId>!
      <artifactId>maven-release-plugin</artifactId>!
      <version>2.0</version>!
      <configuration>!
       <useReleaseProfile>false</useReleaseProfile>!
       <releaseProfiles>myreleaseprofile</
   releaseProfiles>!                                   Don’t use the default
      </configuration>!
                                                       profile
    </plugin>!                                         Use our customized
   </plugins>!
  </pluginManagement>!                                 profile
 </build>!
 ...!
 <profiles>!
  <profile>!
   <id>myreleaseprofile</id>!
   <build>!
    ...!                                               Our customized profile
   </build>!
  </profile>!                                          Customize the behavior
 </profiles>!
 ...!
                                                       of the build for a release
</project>!                                            Take care to test is
                                                       before the release !!

                                               100
Apache Maven
SETUP A GLOBAL MIRROR



               101
Why should we setup a global mirror ?

•  To simplify users and projects settings
•  To control where binaries are coming from
     » To not rely on project’s repositories
     » To use only the corporate repository manager
•    To improve build performances
     » By reducing the number of requests to find a
       missing artefact




                            102
How should we setup a global mirror ?
 <setting>

   <mirrors>

     <mirror>

       <id>global-mirror</id>

       <mirrorOf>external:*</mirrorOf>

       <url>http://repo.acme.com/public</url>

       <url>http://repo.acme.com/public</url>                 Send all requests to this url
     </mirror>

   </mirrors>

   <profiles>

     <profile>

       <id>mirror</id>

       <repositories>

         <repository>

            <id>central</id>

            <url>http://central</url>

            <releases><enabled>true</enabled></releases>

            <releases><enabled>true</enabled></releases>
                                                              Use « central » id to
            <snapshots><enabled>true</enabled></snapshots>

            <snapshots><enabled>true</enabled></snapshots>    override default maven
         </repository>

                                                              configuration
       </repositories>

       <pluginRepositories>

                                                              Enable snapshots
         <pluginRepository>

            <id>central</id>

            <url>http://central</url>

            <releases><enabled>true</enabled></releases>

            <snapshots><enabled>true</enabled></snapshots>

         </pluginRepository>

       </pluginRepositories>

     </profile>

   </profiles>

   <activeProfiles>

     <activeProfile>mirror</activeProfile>

   </activeProfiles>

 </settings>     !
                                                              make the profile active all
                                                              the time

                                              103
Apache Maven
TO GO FURTHER …
Apache Maven
IDE



               105
Eclipse

•    Integration from maven (eclipse:eclipse)
     » Allow many customizations
     » Support many versions/variants of eclipse
     » Support many usages (ear …)
     » Doesn’t support projects with “pom” packaging
     » Few support from dev team
     » Many bugs in classpath management
     » Asynchronous
       •  You have to regenerate and reload project each time you
          change a POM)


                                  106
Eclipse

•    Integration from eclipse (m2eclipse)
     » Synchronous
     » Nice UI and services to edit POMs
     » Support projects with “pom” packaging
     » Doesn’t support all usages like EAR with WTP
     » Doesn’t support very well a large number of
       modules
     » Slow down eclipse on large projects because of a
       lack of support of incremental build in Maven 2.x
       and its plugins


                             107
Eclipse (m2eclipse)




                      108
Eclipse (m2eclipse)




                      109
Eclipse (m2eclipse)




                      110
Idea IntelliJ




                111
Netbeans




           112
Apache Maven
COMMUNITY



               113
Users Mailing List

•    users@maven.apache.or                •    Blue :
     g                                         » Number of subscribers
     » Traffic statistics cover a
       total of 2025 days.                •    Red :
     » Current subscribers: 1936               » Number of messages
     » Current digest                            per day
       subscribers: 48
     » Total posts (2025 days):
        89687
     » Mean posts per day:
        44.29
•    http://pulse.apache.org/

                                    114
Apache Maven Web Site




                   115
Dowloads

Per month downloads
http://people.apache.org/~vgritsenko/stats/
 projects/maven.html




                       116
The team

•  60 committers,
•  More than 30 active in 2009,

•  Several organizations like Sonatype, deliver
   resources and professional support,
•  A community less isolated : more interactions
   with Eclipse, Jetty,




                        117
Commit Statistics




•    In light blue the number of active commiters




                           118
Apache Maven
DOCUMENTATIONS



               119
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




                              120
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

                              121
Books

•    Sonatype / O’Reilly :
     » The Definitive Guide
     » http://
       www.sonatype.com/
       books
     » Free download
     » Available in several
       languages




                              122
Books

•    Apache Maven 2
     Effective
     Implementation
     » Brett Porter, Maria
       Odea Ching
     » https://
       www.packtpub.com/
       apache-maven-2-
       effective-
       implementation/book


                             123
Books

•    Exist Global
     » Better builds with
       Maven
     » http://
       www.maestrodev.com
       /better-build-maven
     » Free download




                             124
Apache Maven
SUPPORT



               125
Support

•    Mailing lists
     » http://maven.apache.org/mail-lists.html
•    IRC
     » irc.codehaus.org - #maven
•    Forums
     » http://www.developpez.net/ forum maven
     » In French
•    Dedicated support
     » Sonatype and many others companies

                             126
Apache Maven
QUESTIONS ?



               127
Licence et copyrights

•  Photos and logos belong to their respective
   authors/owners
•  Various ideas are coming from the excellent
   presentation done by Matthew McCullough :
     » http://www.slideshare.net/matthewmccullough/
      maven-30-at-oredev




                           128
Licence et copyrights

•    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/




                                      129

Más contenido relacionado

La actualidad más candente

Riviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - MavenRiviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - MavenArnaud Héritier
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
Geneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenGeneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenArnaud Héritier
 
Alpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenAlpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenArnaud Héritier
 
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 promisesArnaud Héritier
 
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 promisesArnaud Héritier
 
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 promisesArnaud Héritier
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsNETWAYS
 
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksBuilding Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksAtlassian
 

La actualidad más candente (19)

4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Riviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - MavenRiviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - Maven
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Geneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenGeneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - Maven
 
Alpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenAlpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache Maven
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
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
 
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
 
Maven
Maven Maven
Maven
 
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
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy Hawkins
 
Maven for eXo VN
Maven for eXo VNMaven for eXo VN
Maven for eXo VN
 
MAVEN
MAVENMAVEN
MAVEN
 
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksBuilding Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
 
Introduction to maven
Introduction to mavenIntroduction to maven
Introduction to maven
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 

Destacado

Destacado (7)

Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache maven 2. advanced topics
Apache maven 2. advanced topicsApache maven 2. advanced topics
Apache maven 2. advanced topics
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Maven university-course
Maven university-courseMaven university-course
Maven university-course
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Capitulo1 generalidades
Capitulo1 generalidadesCapitulo1 generalidades
Capitulo1 generalidades
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 

Similar a Apache Maven - eXo TN presentation

How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.Fazreil Amreen Abdul Jalil
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using MavenScheidt & Bachmann
 
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment ToolsBP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment ToolsAlfresco Software
 
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éritierGenevaJUG
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to MavenEric Wyles
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
Practical maven-slides 2
Practical maven-slides 2Practical maven-slides 2
Practical maven-slides 2Will Iverson
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with MavenMika Koivisto
 
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 promisesArnaud Héritier
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svnAnkur Goyal
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaEdureka!
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topicGourav Varma
 
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...Martin Bergljung
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 
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 trackArnaud Héritier
 

Similar a Apache Maven - eXo TN presentation (20)

How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment ToolsBP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
 
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
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Practical maven-slides 2
Practical maven-slides 2Practical maven-slides 2
Practical maven-slides 2
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
 
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
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
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...
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
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
 
Apache Maven 2 Part 2
Apache Maven 2 Part 2Apache Maven 2 Part 2
Apache Maven 2 Part 2
 
Intro to Maven.ppt
Intro to Maven.pptIntro to Maven.ppt
Intro to Maven.ppt
 

Más de Arnaud Héritier

Devops Recto-Verso @ DevoxxMA
Devops Recto-Verso @ DevoxxMADevops Recto-Verso @ DevoxxMA
Devops Recto-Verso @ DevoxxMAArnaud Héritier
 
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 railsArnaud Héritier
 
Sonar In Action 20110302-vn
Sonar In Action 20110302-vnSonar In Action 20110302-vn
Sonar In Action 20110302-vnArnaud Héritier
 
2014 August - eXo Software Factory Overview
2014 August - eXo Software Factory Overview2014 August - eXo Software Factory Overview
2014 August - eXo Software Factory OverviewArnaud Héritier
 
CRaSH @ JUGSummerCamp 2012 - Quickie
CRaSH @ JUGSummerCamp 2012 - QuickieCRaSH @ JUGSummerCamp 2012 - Quickie
CRaSH @ JUGSummerCamp 2012 - QuickieArnaud Héritier
 
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 promisesArnaud Héritier
 
Hands on iOS developments with jenkins
Hands on iOS developments with jenkinsHands on iOS developments with jenkins
Hands on iOS developments with jenkinsArnaud Héritier
 
eXo Software Factory Overview
eXo Software Factory OvervieweXo Software Factory Overview
eXo Software Factory OverviewArnaud Héritier
 
Mobile developments at eXo
Mobile developments at eXoMobile developments at eXo
Mobile developments at eXoArnaud Héritier
 
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 JenkinsArnaud Héritier
 
Apache Maven - eXo VN office presentation
Apache Maven - eXo VN office presentationApache Maven - eXo VN office presentation
Apache Maven - eXo VN office presentationArnaud Héritier
 
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?Arnaud Héritier
 
20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache Maven20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache MavenArnaud Héritier
 
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 MavenArnaud Héritier
 
20081008 - Tours Jug - Apache Maven
20081008  - Tours Jug - Apache Maven20081008  - Tours Jug - Apache Maven
20081008 - Tours Jug - Apache MavenArnaud Héritier
 
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 MavenArnaud Héritier
 
20080513 - Paris Jug - Maven à La Demande
20080513 - Paris Jug - Maven à La Demande20080513 - Paris Jug - Maven à La Demande
20080513 - Paris Jug - Maven à La DemandeArnaud Héritier
 
20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache Maven20081113 - Nantes Jug - Apache Maven
20081113 - Nantes Jug - Apache MavenArnaud Héritier
 
20091020 - Normandy Jug - Builders Battle
20091020 - Normandy Jug - Builders Battle20091020 - Normandy Jug - Builders Battle
20091020 - Normandy Jug - Builders BattleArnaud Héritier
 

Más de Arnaud Héritier (19)

Devops Recto-Verso @ DevoxxMA
Devops Recto-Verso @ DevoxxMADevops Recto-Verso @ DevoxxMA
Devops Recto-Verso @ DevoxxMA
 
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
 
Sonar In Action 20110302-vn
Sonar In Action 20110302-vnSonar In Action 20110302-vn
Sonar In Action 20110302-vn
 
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
 
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
 
Hands on iOS developments with jenkins
Hands on iOS developments with jenkinsHands on iOS developments with jenkins
Hands on iOS developments with jenkins
 
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
 
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
 

Último

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Último (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Apache Maven - eXo TN presentation

  • 2. Arnaud Héritier •  eXo - Software Factory Manager »  In charge of tools and methods •  Apache Maven : »  Committer since 2004 and member of the Project Management Committee •  Coauthor of « Apache Maven » »  published by Pearson (in French) •  Contact me : »  http://aheritier.net »  Twitter : @aheritier »  Skype : aheritier 2
  • 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 standards/conventions driven » How many of you are doing JEE and related developments ? 4
  • 5. History •  Initiated in 2001 by Jason Van Zyl in Alexandria, an Apache Jakarta project, •  Moved to Turbine few months after, •  Became a Top Level Project in 2003. •  Maven 2.0 released in September 2005 •  Maven 3.0 released in October 2010 » 3.0.4 – January 2012 5
  • 6. Choose your way of thinking Conventions approach Scripting approach 6
  • 7. Competitors •  Ant + Ivy, Easy Ant, Gant, Gradle, Buildr… •  Script oriented »  You can do what you want ! •  Reuse many of Maven conventions (directories layout, …) and services (repositories) but without enforcing them •  The risk for them : Not being able to evolve due to the too high level of customization proposed to the user. »  We tried on Maven 1 and it died because of that. It was impossible to create a set of tests to cover all usages. »  It’s like providing a framework without a well tested set of public API L 7
  • 8. With scripts oriented builds You can have But often you have (if you have good skills) (moreover after years …) 8
  • 9. With Maven We dream to deliver But yesterday we too often had (Maven 3.x) (Maven 2.x) 9
  • 11. Your menu •  Concepts •  Apache Maven 3.x •  Good and bad practices •  Usecases 11
  • 13. Conventions •  1 project = 1 artifact (pom, jar, war, ear, …) •  Standardized » project descriptor (POM) » build lifecycle » directories layout •  *.java to compile in src/[main|test]/java •  *.xml, *.properties needed in classpath and to bundle in archive in src/[main|test]/resources •  target directory for generated stuffs (sources, classes, …) •  … 13
  • 14. POM •  An XML file (pom.xml) <?xml version="1.0" encoding="UTF-8"?>! <project>! <modelVersion>4.0.0</modelVersion>! <groupId>net.aheritier.samples</groupId>! •  Describing <artifactId>simple-webapp</artifactId>! <version>1.1-SNAPSHOT</version>! » Project identification <packaging>war</packaging>! <name>Simple webapp</name>! » Project version <inceptionYear>2007</inceptionYear>! <dependencies>! » Project description <dependency>! <groupId>org.springframework</groupId>! » Build settings <artifactId>spring-struts</artifactId>! <version>2.0.2</version>! </dependency>! » Dependencies ...! </dependencies>! » … </project>! 14
  • 15. Reactor •  Split your project in sub-modules <project>! •  Maven computes the ...! build order from <modules>! <module>moduleA</module> ! dependencies <module>moduleB</module> ! between sub- <module>moduleC</module> ! modules. <module>moduleD</module> ! <module>moduleE</module> ! •  Modules have to be <module>moduleF</module> ! defined in the POM </modules>! » No auto-discovery for ...! performance reasons </project>! 15
  • 16. Inheritance •  Share settings between projects/modules •  By default the parent project is supposed to be in the parent directory (../) <parent>! <groupId>net.aheritier.sample</groupId>! <artifactId>my-parent</artifactId>! <version>1.0.0-SNAPSHOT<version>! </parent>! 16
  • 17. Inheritance Use a technical inheritance to organize sub- modules Use assembly to package batchs Insert README in all artifacts Use clirr to validate backward compatibility 17
  • 18. 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 18
  • 19. Artifact Repository •  By default Maven downloads artifacts required by the project or itself from central •  Downloaded artifacts are stored in the local repository •  Used to store : » Project’s binaries » Project’s dependencies » Maven and plug-ins binaries 19
  • 20. Dependencies Without Maven With Maven 20
  • 21. 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 21
  • 22. 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 22
  • 23. Dependencies •  Define all dependencies you are using » and no more ! •  If you have optional dependencies » Perhaps you should have optional modules instead •  Cleanup your dependencies with » mvn dependency:analyze! •  Study your dependencies with » mvn dependency:tree! » mvn dependency:list! 23
  • 24. 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 24
  • 25. Versions 25
  • 26. 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 L •  The release plugin will enforce it J 26
  • 27. Versions •  Range » From … to … » Maven automatically searches for the corresponding version (using the update policy for released artifacts) » To use with caution •  Risk of non reproducibility of the build •  Risk of side effects on projects depending on yours. 27
  • 28. Versions •  Use the versions plugin to update all versions of your project and its modules mvn versions:set –DnewVersion=A.B.C-SNAPSHOT! 28
  • 29. 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! 29
  • 30. Profiles ●  activeByDefault = If no other profile is activated ●  Activation through Maven settings <settings>! ...! <activeProfiles>! <activeProfile>profile-1</activeProfile>! </activeProfiles>! ...! </settings>! 30
  • 31. Profiles •  Activation based on environment variables <profiles>! <profiles>! <profile>! <profile>! <activation>! <activation>! <property>! <property>! <name>run-its</name>! <name>!skip-enforce</name>! <value>true</value>! </property>! </property>! </activation>! </activation>! ...! ...! </profile>! </profile>! </profiles>! </profiles>! 31
  • 32. Profiles •  OS / Java settings <profiles>! <profile>! <activation>! <profiles>! <os>! <profile>! <name>Windows XP</name>! <activation>! <family>Windows</family>! <jdk>[1.3,1.6)</jdk>! <arch>x86</arch>! </activation>! <version>5.1.2600</version>! ...! </os>! </profile>! </activation>! </profiles>! ...! </profile>! </profiles>! 32
  • 33. Profiles •  Activation on present or missing files <profiles>! <profile>! <activation>! <file>! <missing>${project.build.directory}/generated-sources/ axistools/wsdl2java/</missing>! </file>! </activation>! ...! </profile>! </profiles>! 33
  • 34. Build Lifecycle And Plugins •  Plugin based architecture for a great extensibility •  Standardized lifecycle to build all types of archetypes 34
  • 35. Build Lifecycle And Plugins Default Lifecycle Clean Lifecycle Site Lifecycle validate pre-clean pre-site initialize clean site generate-sources post-clean post-site process-sources site-deploy generate-resources process-resources compile process-classes generate-test-sources process-test-sources generate-test-resources process-test-resources test-compile process-test-classes test prepare-package package pre-integration-test integration-test post-integration-test verify install deploy 35
  • 36. Build Lifecycle And Plugins •  Many plugins » Packaging » Reporting » IDE integration » Miscellaneous tools integration •  Many locations » maven.apache.org » mojo.codehaus.org » code.google.com » … Take care while selecting them !!! 36
  • 38. Apache Maven 3.x BACKWARD COMPATIBILITY 38
  • 39. Backward compatibility - Criticisms •  Migration from Maven 1 to Maven 2 was impossible. Everything had to be re-done. •  Updates between 2.x versions and also between 2.0.x weren’t often without side effects. 39
  • 40. Backward compatibility •  Near to 700 integration tests •  Tested for several months on a large set of OSS projects •  7 alphas + 3 betas versions •  A bug fix release every 6 weeks •  It’s a revolution under the hood but an evolution for end users 40
  • 41. Maven 3.0.x ITs 674 41
  • 43. Performances - Criticisms •  Maven is slow •  It spends its time to download the world •  Whereas everybody has multicore CPUs, it doesn’t allow to process modules builds in parallel 43
  • 44. Performances •  A set of benchmark tools was developed to measure Maven performances (IO, CPU, Memory, Network …) •  Startup and execution times are reduced » Java 5 optimizations » Code cleanup and improvements •  Reduced Memory footprint •  Artifacts Resolution Caching » .lastUpdated files in your local repo » Enforce checks with –U option 44
  • 45. Performances – Parallel builds •  Parallel builds » An execution plan is predefined at startup to define which modules could be built in // » Requires to have up to date plugins to avoid dead locks and some others issues » Launch a build with 2 threads •  mvn –T 2 install » Launch a build with 2 threads per CPU core •  mvn –T 2C install 45
  • 46. Performances – mvnsh •  Performances optimizations » Intelligent cache system (artifacts resolution, project descriptors …) » No need to restart a JVM for each build •  Cross platform « unix like » shell » Alias, environment settings … » Color highlighting 46
  • 47. Performances – mvnsh •  All in one » Includes Maven 3.x » Allows to have color highlighting with “standard” Maven 3.x •  Developed and freely distributed by Sonatype 47
  • 50. Extensibility - Criticisms •  It is difficult and time consuming to extend maven (write plugins) » Many unknown technologies like Plexus for IOC •  It is difficult/impossible to reuse maven plugins » Its impossible to extend plugins/mojo and lifecycles 50
  • 51. Extensibility •  New APIs to improve abstraction of underneath implementation » Aether : to manage artifacts and repositories •  Plugin classloader partitioning •  Embeddable •  IOC replaced by Guice » For now (3.0) a wrapper is hiding the change » You don’t yet use Guice directly (from plugins for example) 51
  • 53. Robustness - Criticisms •  Builds aren’t predictable •  Errors are difficult to diagnose 53
  • 54. Robustness - Validations •  Many more validations in POMs (warnings or errors) » Missing plugins versions » Duplicated dependencies in a POM » Incoherent inheritance (wrong relative path or parent not in the upper directory) •  Improved error messages with links to wiki pages for more detailed information 54
  • 55. Robustness – Artifacts management •  Parent POMs prefer to resolve from repositories » Version less parent will be available in a future maven 3.x release by using the relativePath element •  Profiles usage consolidation » No more profiles.xml (incompatible with future polyglot feature) 55
  • 56. Robustness – Artifacts management •  No more support for legacy repository layout for Maven 1.0 •  SNAPSHOTs are always deployed with timestamps 56
  • 57. Robustness – Plugins management •  Plugin version is by default RELEASE and no more SNAPSHOT » Affects command-line invocation •  Plugins cannot use versions LATEST or RELEASE » Affects command-line invocation and POM •  Plugins are resolved only from <pluginRepository> entries 57
  • 58. Robustness – Site plugin •  Site plugin is now completely extracted from Maven core » It has its own lifecycle » reporting section in POM becomes useless (moved in plugin configuration) 58
  • 60. Criticisms •  XML, we don’t like it •  POM is too verbose •  POM v4 didn’t evolve last 5 years » When will you add new common attributes to ease plugins configuration (encoding …) » New feature like global exclusions 60
  • 61. POM •  No change in POM syntax for Maven 3.0 •  Changes will occur in 3.x versions » New model with a new version » Only new things » Generation / deployment of 4.0.0 current POM to keep backward compatibility with old maven versions •  Mixins to allow to import POM fragments 61
  • 62. POM - Polyglot •  Developed and freely distributed by Sonatype •  Extended version of Maven 3.0 using its new embedding and extensibility capabilities •  Allow translation (read/write) from/to various syntaxes » Yaml » Scala » Groovy •  Allow macros and freeform scripting 62
  • 63. Apache Maven GOOD & BAD PRACTICES
  • 65. 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 •  … 65
  • 67. 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 ? 67
  • 68. 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 … 68
  • 69. 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 … 69
  • 70. Apache Maven POM GOOD & BAD PRACTICES 70
  • 71. 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 71
  • 72. 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. 72
  • 73. 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. 73
  • 75. 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 75
  • 76. 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) 76
  • 78. Apache Maven SECURE YOUR CREDENTIALS 78
  • 79. Secure your credentials l  Generate a private key -  
 arnaud@leopard:~$ mvn --encrypt-master-password toto
 {dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}
 ! ●  We save the private key in ~/.m2/settings-security.xml <settingssecurity>! <master>{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}</ master>! </settingssecurity>! 79
  • 80. Secure your credentials ●  You can move this key to another drive ~/.m2/ settings.xml -  <settingsSecurity>
 <relocation>/Volumes/ArnaudUsbKey/secure/settings-security.xml</relocation>
 </settingsSecurity>! ●  You create an encrypted version of your server password -  arnaud@mbp-arnaud:~$ mvn --encrypt-password titi{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}! ●  You register it in your settings -  <settings>
 ...
 <servers>
 ...
 <server>
 <id>mon.server</id>
 <username>arnaud</username>
 <password>{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}</password>
 </server>
 ...
 </servers>
 ...
 </settings>! 80
  • 81. Apache Maven BUILD A PART OF YOUR PROJECT 81
  • 82. Using Reactor Options •  Options added in maven 2.1 •  Available in 2.0.x with the maven-reactor- plugin » But syntax is longer •  Allow to control what you want to build in your project 82
  • 83. Using Reactor Options - -  arnaud@mbp-arnaud:~$ mvn install
 install [INFO] ------------------------------------------------
 ------------------------------------------------ [INFO] Reactor Summary: Summary:
 [INFO]
 [INFO] [INFO] Project ....................... SUCCESS [2.132s]
 [2.132s] [INFO] ModuleA ....................... SUCCESS [5.574s]
 [5.574s] [INFO] ModuleB ....................... SUCCESS [0.455s]
 [0.455s] [INFO] ModuleC ....................... SUCCESS [0.396s]
 [0.396s] [INFO] ModuleD ....................... SUCCESS [0.462s]
 [0.462s] [INFO] ModuleE ....................... SUCCESS [0.723s]
 [0.723s] [INFO] ModuleF ....................... SUCCESS [0.404s]! [0.404s] l l  Builds everything from A to F 83
  • 84. Using Reactor Options - -  arnaud@mbp-arnaud:~$ mvn install –pl moduleE,moduleB
 moduleE,moduleB -------------------------------------------
 [INFO] ------------------------------------------- Summary:
 [INFO] Reactor Summary: [INFO]
 [INFO] [2.774s]
 [INFO] ModuleB .................. SUCCESS [2.774s] [1.008s]
 [INFO] ModuleE .................. SUCCESS [1.008s] ! l l  Builds only modules B and E l l  Following dependencies order l l  -pl --project-list: Build the specified reactor projects instead of all projects 84
  • 85. Using Reactor Options - -  arnaud@mbp-arnaud:~$ mvn install –pl moduleD -am
 ------------------------------------------
 [INFO] ------------------------------------------ Summary:
 [INFO] Reactor Summary: [INFO]
 [INFO] [4.075s]
 [INFO] ModuleA ................. SUCCESS [4.075s] [0.468s]
 [INFO] ModuleB ................. SUCCESS [0.468s] [0.354s]
 [INFO] ModuleC ................. SUCCESS [0.354s] [0.384s]
 [INFO] ModuleD ................. SUCCESS [0.384s] ! l l  Builds module D (-pl) and all modules it uses as dependencies l l  -am --also-make: If a project list is specified, also make projects that the list depends on l l  Usecase : Build all modules required for a war, ear, … 85
  • 86. Using Reactor Options - -  arnaud@mbp-arnaud:~$ mvn install –pl moduleD -amd
 ------------------------------------------
 [INFO] ------------------------------------------ Summary:
 [INFO] Reactor Summary: [INFO]
 [INFO] [4.881s]
 [INFO] ModuleD ................. SUCCESS [4.881s] [0.478s]
 [INFO] ModuleE ................. SUCCESS [0.478s] [0.427s]
 [INFO] ModuleF ................. SUCCESS [0.427s] ! l l  Builds module D (-pl) and all modules which depend on it l l  -amd --also-make-dependents: If a project list is specified, also make projects that depend on projects on the list l l  Usecase : Check that a change in a module didn’t break others which are using it 86
  • 87. Using Reactor Options - -  arnaud@mbp-arnaud:~$ mvn install –rf moduleD
 ------------------------------------------
 [INFO] ------------------------------------------ Summary:
 [INFO] Reactor Summary: [INFO]
 [INFO] [9.707s]
 [INFO] ModuleD ................. SUCCESS [9.707s] [0.625s]
 [INFO] ModuleE ................. SUCCESS [0.625s] [INFO] ModuleF ................. SUCCESS [0.679s] [2.467s]
 [INFO] Project ................. SUCCESS [2.467s] ! l l  Restarts all the build from module D (-rf) l l  -rf,--resume-from <arg> : Resume reactor from specified project l l  Usecase : The build failed a 1st time in module D, you fixed it, and restart the build were it was to end it. 87
  • 89. Release of a webapp in 2002 •  Limited usage of eclipse » No WTP (Only some features in WSAD), » No ability to produce WARs 89
  • 90. Release of a webapp in 2002 •  Many manual tasks » Modify settings files » Package JARs » Copy libraries (external and internal) in a « lib » directory » Package WAR (often with a zip command) » Tag the code (CVS) » Send the package on the integration server using FTP » Deploy the package with AS console 90
  • 91. Release of a webapp in 2002 •  One problem : The are •  How long did it take ? always problems » When everything is » Error in config files ok : 15 minutes »  Missing dependencies » When there’s a »  Missing file problem : ½ day or »  Last minute fix which created a more bug »  And many other possibilies .. 91
  • 92. Maven Release Plugin •  Automates the release process from tagging sources to binaries delivery •  Release plugin main goals: » Prepare : To update maven versions and information in POMs and tag the code » Perform : To deploy binaries in a maven repository •  After that you can just automate the deployment on the AS using cargo for example. 92
  • 94. Configuration and Prerequisites •  Project version (must be a SNAPSHOT version) •  Dependencies and plugins versions mustn’t be SNAPSHOTs 94
  • 95. Troubleshooting Releases •  Common errors during release: » Build with release profile was tested before and fails » Local modifications » Current version is not a SNAPSHOT » SNAPSHOTs in dependencies and/or plugins » Missing some configuration (scm, distribMgt, …) » Tag already exists » Unable to deploy project to the Repository » Connection problems 95
  • 96. SCM configuration SCM binaries have to be in the PATH SCM credentials have to already be stored or you have to pass them in command line with : –Dusername=XXX –Dpassword=XXX <scm>! <connection>scm:svn:http://svn.acme.com/myproject/trunk</connection>! <developerConnection>scm:svn:https://svn.acme.com/myproject/trunk</developerConnection>! <url>http://fisheye.acme.com/browse/myproject/trunk</url>! </scm>! 96
  • 97. Distribution Management •  Where you want to upload released binaries » The url of a repository dedicated for your project/ corporate maven deliveries in your repository manager <project>! <distributionManagement>! <repository>! <id>repository.acme.com</id>! <url>${acme.releases.repo.url}</url>! This id will be used in </repository>! user’s maven settings . . .! (~/.m2/settings.xml) </distributionManagement>! . . . ! <properties>! <acme.releases.repo.url>http://repo.acme.com/acme-releases</acme.releases.repo.url>! . . .! </properties>! </project>! Often useful to have a property to test the release process on a fake repository, to validate a repo manager ... 97
  • 98. Repository credentials •  One server entry is required per different repository id in distribution management of projects •  In a corporate environment, use a unique id for all repositories hosted on repository managers using same credentials (corporate LDAP …) <settings>! ...! <servers>! <server>! <id>repository.acme.com</id>! <username>aheritier</username>! This id is the one defined in <password>{ABCDEFGHIJKLMNOPQRSTUVWYZ}</password> <password>{ABCDEFGHIJKLMNOPQRSTUVWYZ}</password>! distributionManagement </server>! ...! entry of the project to </servers>! release ...! </settings>! 98
  • 99. Default Release Profile in Super POM •  This profile is used when you generate binaries of the release with “mvn release:perform” •  By default, generates sources and javadocs jars for each module. <profile>! <id>release-profile</id>! <activation>! <property>! <name>performRelease</name>! <value>true</value>! This activation could be </property>! </activation>! used in profiles you want to <build>! activate in the release <plugins>! process ...! </plugins>! </build>! Configuration to generate </profile>! sources and javadoc jars with basic setting 99
  • 100. Custom release profile <project>! ...! <build>! <pluginManagement>! <plugins>! <plugin>! <groupId>org.apache.maven.plugins</groupId>! <artifactId>maven-release-plugin</artifactId>! <version>2.0</version>! <configuration>! <useReleaseProfile>false</useReleaseProfile>! <releaseProfiles>myreleaseprofile</ releaseProfiles>! Don’t use the default </configuration>! profile </plugin>! Use our customized </plugins>! </pluginManagement>! profile </build>! ...! <profiles>! <profile>! <id>myreleaseprofile</id>! <build>! ...! Our customized profile </build>! </profile>! Customize the behavior </profiles>! ...! of the build for a release </project>! Take care to test is before the release !! 100
  • 101. Apache Maven SETUP A GLOBAL MIRROR 101
  • 102. Why should we setup a global mirror ? •  To simplify users and projects settings •  To control where binaries are coming from » To not rely on project’s repositories » To use only the corporate repository manager •  To improve build performances » By reducing the number of requests to find a missing artefact 102
  • 103. How should we setup a global mirror ? <setting>
 <mirrors>
 <mirror>
 <id>global-mirror</id>
 <mirrorOf>external:*</mirrorOf>
 <url>http://repo.acme.com/public</url>
 <url>http://repo.acme.com/public</url> Send all requests to this url </mirror>
 </mirrors>
 <profiles>
 <profile>
 <id>mirror</id>
 <repositories>
 <repository>
 <id>central</id>
 <url>http://central</url>
 <releases><enabled>true</enabled></releases>
 <releases><enabled>true</enabled></releases> Use « central » id to <snapshots><enabled>true</enabled></snapshots>
 <snapshots><enabled>true</enabled></snapshots> override default maven </repository>
 configuration </repositories>
 <pluginRepositories>
 Enable snapshots <pluginRepository>
 <id>central</id>
 <url>http://central</url>
 <releases><enabled>true</enabled></releases>
 <snapshots><enabled>true</enabled></snapshots>
 </pluginRepository>
 </pluginRepositories>
 </profile>
 </profiles>
 <activeProfiles>
 <activeProfile>mirror</activeProfile>
 </activeProfiles>
 </settings> ! make the profile active all the time 103
  • 104. Apache Maven TO GO FURTHER …
  • 106. Eclipse •  Integration from maven (eclipse:eclipse) » Allow many customizations » Support many versions/variants of eclipse » Support many usages (ear …) » Doesn’t support projects with “pom” packaging » Few support from dev team » Many bugs in classpath management » Asynchronous •  You have to regenerate and reload project each time you change a POM) 106
  • 107. Eclipse •  Integration from eclipse (m2eclipse) » Synchronous » Nice UI and services to edit POMs » Support projects with “pom” packaging » Doesn’t support all usages like EAR with WTP » Doesn’t support very well a large number of modules » Slow down eclipse on large projects because of a lack of support of incremental build in Maven 2.x and its plugins 107
  • 112. Netbeans 112
  • 114. Users Mailing List •  users@maven.apache.or •  Blue : g » Number of subscribers » Traffic statistics cover a total of 2025 days. •  Red : » Current subscribers: 1936 » Number of messages » Current digest per day subscribers: 48 » Total posts (2025 days): 89687 » Mean posts per day: 44.29 •  http://pulse.apache.org/ 114
  • 115. Apache Maven Web Site 115
  • 117. The team •  60 committers, •  More than 30 active in 2009, •  Several organizations like Sonatype, deliver resources and professional support, •  A community less isolated : more interactions with Eclipse, Jetty, 117
  • 118. Commit Statistics •  In light blue the number of active commiters 118
  • 120. 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 120
  • 121. 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 121
  • 122. Books •  Sonatype / O’Reilly : » The Definitive Guide » http:// www.sonatype.com/ books » Free download » Available in several languages 122
  • 123. Books •  Apache Maven 2 Effective Implementation » Brett Porter, Maria Odea Ching » https:// www.packtpub.com/ apache-maven-2- effective- implementation/book 123
  • 124. Books •  Exist Global » Better builds with Maven » http:// www.maestrodev.com /better-build-maven » Free download 124
  • 126. Support •  Mailing lists » http://maven.apache.org/mail-lists.html •  IRC » irc.codehaus.org - #maven •  Forums » http://www.developpez.net/ forum maven » In French •  Dedicated support » Sonatype and many others companies 126
  • 128. Licence et copyrights •  Photos and logos belong to their respective authors/owners •  Various ideas are coming from the excellent presentation done by Matthew McCullough : » http://www.slideshare.net/matthewmccullough/ maven-30-at-oredev 128
  • 129. Licence et copyrights •  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/ 129