SlideShare a Scribd company logo
1 of 51
Download to read offline
Object Oriented and beyond




Maven 2 in the real world
       Carlo Bonamico
    carlo.bonamico@gmail.com

         JUG Genova



         Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                            Javaday Roma III Edizione – 24 gennaio 2009
Maven2: love it or hate it?

    Widespread build platform
●


         used by many open source and commercial projects
     –

    PROs
●


         automatic dependency management
     –

         good tool/IDE support
     –

         automate the entire build life cycle
     –

         highly configurable                                           also...
     –
                                                                  lots of tutorials
    CONs                                                         on simple cases,
●
                                                               less documentation
                                                                on complex builds
         highly configurable :-)
     –

         too much XML...
     –

                               Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                  Javaday Roma III Edizione – 24 gennaio 2009
Presentation goals

    Maven can be your friend (and save lots of time!)
●


        if you
    –

                learn it and understand it
            ●


                use it in the right way
            ●



    My talk is about how to maximize usefulness and
●

    efficiency
        while minimizing complexity & overhead
    –

    Sharing real world experience
●


            in designing and managing the build process for
        –
            several large projects (>20 modules, >100 kLoc)
                                  Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                     Javaday Roma III Edizione – 24 gennaio 2009
Part 1




Maven2 in 5 minutes




    Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                       Javaday Roma III Edizione – 24 gennaio 2009
Maven2 in 5 minutes

    Maven is a modular automation system built
●

    around 4 main elements
                            repository
          POM


                              Maven

                                             Plugins
          src



         input: project src/resources + POM
     –

         output: tested and packaged artifact
     –

                         Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                            Javaday Roma III Edizione – 24 gennaio 2009
Maven in 5': the POM

    The Project Object Model describes
●


         project coordinates
     –
                                                             groupId: net.juggenova
                                                                artifactId: sample
         project type
     –
                                                                   version: 1.0
                packaging (JAR, WAR, EAR, POM)
            ●



         source structure
     –

         build phases
     –

                standard + custom
            ●



         dependencies
     –

         plugins
     –



                            Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                               Javaday Roma III Edizione – 24 gennaio 2009
Maven in 5': build lifecycle

    Default life cycle                       Every goal implies all
●                                        ●

                                             the previous ones
                   validate
               –
                   generate-sources
               –
                                                               mvn compile
                                                           –
                   process-resources
               –
                                                   actually executes
                                               –
                   compile
               –
                                                               validate
                                                           –
                   test-compile
               –
                                                               generate-sources
                                                           –
                   test
               –
                                                               process-resource
                                                           –
                   package
               –
                                                               compile
                                                           –
                   integration-test
               –
                   verify
               –
                                             Stand-alone goals
                                         ●
                   install
               –
                   deploy
               –
                                                               mvn scm:update
                                                           –
         (some skipped for clarity)
     –


                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
Maven in 5':
                              Dependency Management
    Dependencies
●


         include all external libraries and files needed to
     –
         completely assemble the output
                JARs, WARs, ZIPs, POMs
            ●



         are versioned
     –

         can be transitive
     –

                e.g. include just spring, get commons-logging
            ●

                  automatically
    Conflict resolution mechanism
●


         determines the version to be used when a jar is
     –
         included multiple times
                             Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                Javaday Roma III Edizione – 24 gennaio 2009
Maven in 5': repositories

    Maven repository
●


            a structured store containing artifacts (JAR, WAR, ZIP...)
        –

    Maven uses at leas two
●


            local repository – on your PC
        –

            central repository – http://repo1.maven.org/maven2/
        –

    Three types of repositories
●

                                                                         local repository
        plain filesystem folder
    –
                                                                         ${user.home}/
        folder served by HTTP daemon
    –
                                                                         .m2/repository
               populated via SCP/FTP/WEBDAV
             ●


            full β€œintelligent” repository (with indexing, search, cache, ...)
    –

                                 Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                    Javaday Roma III Edizione – 24 gennaio 2009
From code to repo (and back)


                              deploy

install                                                  remote
                                                       repository

                 local
               repository



package                                                 central
                            resolve                    repository




            Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                               Javaday Roma III Edizione – 24 gennaio 2009
Part 2




Effective maven2




  Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                     Javaday Roma III Edizione – 24 gennaio 2009
Getting the most out of Maven

    Good old sw engineering principles still apply!
●


    Don't repeat yourself
●

                                                                      things
        the DRY principle
    –                                                            always change
                                                                   in a project
                reduce time, effort, maintenance
            ●


                minimize the impact of changes
            ●



    Separate concerns
●


    Automate as much as possible
●


    Use the right tools (plugins & repositories)
●


    Keep the build fast
●



                             Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                Javaday Roma III Edizione – 24 gennaio 2009
How to minimize XML

    Exploit the three main POM relationships
●


        inheritance, aggregation, dependency
    –


    This is a valid (and working) maven POM
●


                 <project xmlns=quot;...quot; xmlns:xsi=quot;...quot;
             –
                 xsi:schemaLocation=quot;...quot;>
                     ● <modelVersion>4.0.0</modelVersion>

                     ● <groupId>net.juggenova.sample</groupId>

                     ● <artifactId>minimal</artifactId>

                     ● <version>1.0</version>


                 </project>
             –

    How can this work?
●



                           Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                              Javaday Roma III Edizione – 24 gennaio 2009
The Super POM

    Implicitely, all POMs inherit from the Super POM
●


            see http://maven.apache.org/pom.html
        –

    Defines                                                                 Super
●
                                                                            POM

        standard directory structure
    –

        default plugins & repo
    –

                                                                             your
        where it is? inside mvn jars                                         POM
    –

        how to check it?
    –
                    mvn help:effective-pom
                –

    Convention over Configuration
●


                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
The Super-POM

<repos itories >
  <repos itory>
    <id>central</id>
    <name>Maven R epos itory S witchboard</name>
    <url>http://repo1.maven.org /maven2</url>
  </repos itory>
</repos itories >
<build>
  <s ourceDirectory>s rc/main/java</s ourceDirectory>
  <tes tS ourceDirectory>s rc/tes t/java</tes tS ourceDirectory>
  <outputDirectory>targ et/clas s es </outputDirectory>
  ...
  <res ources >
    <res ource>
      <directory>s rc/main/res ources </directory>
    </res ource>
  </res ources >
  <tes tR es ources >...</tes tR es ources >

                               Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                  Javaday Roma III Edizione – 24 gennaio 2009
The Super-POM

<plug inManag ement>
  <plug ins >
     <plug in>
       <artifactId>maven-as s embly-plug in</artifactId>
       <vers ion>2.2-beta-1</vers ion>
     </plug in>
     <plug in>
       <artifactId>maven-compiler-plug in</artifactId>
       <vers ion>2.0.2</vers ion>
     </plug in>
   ...
  </plug ins >
 </plug inManag ement>
</build>




                               Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                  Javaday Roma III Edizione – 24 gennaio 2009
Parent POM: make you own

    Create a POM defining your project conventions
●

    and tools
         additional resource directories
     –

         default plugin configuration
     –

                e.g. custom configuration for maven-compiler-plugin
            ●



         standard libraries
     –

                e.g. default spring version with
            ●


                    <dependencyManagement>
                –

         repositories and deployment config
     –

                e.g. your company repository with
            ●


                    <distributionManagement>
                –

                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
net.juggenova.sample:parent

<build>
  <s ourceDirectory>java/s rc</s ourceDirectory>
  ...
  <plug inManag ement>
    <plug ins >
      <plug in>
      <g roupId>org .apache.maven.plug ins </g roupId>
      <artifactId>maven-compiler-plug in</artifactId>
      <config uration>
        <s ource>1.6</s ource>
        <targ et>1.6</targ et>
      </config uration>
      </plug in>
      <plug in>
       <artifactId>maven-s urefire-plug in</artifactId>
        <config uration>...</config uration>
      </plug in>
    </plug ins >

                               Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                  Javaday Roma III Edizione – 24 gennaio 2009
Parent POM: use it

    Reference the parent at the beginning of a POM
●


                 <parent>
             –
                     ● <artifactId>parent</artifactId>

                     ● <groupId>net.juggenova.sample</groupId>

                     ● <version>1.1</version>

                     ● <relativePath>../parent</relativePath>


                 </parent>
             –

    Useful
●


         if you have many similar projects/components
     –

         to separate responsibilities between senior and
     –
         junior developers
         to encapsulate company-wide settings
     –

                           Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                              Javaday Roma III Edizione – 24 gennaio 2009
Issues and suggestions

    Main issue: children must reference parent
●

    version explicitely
         strong dependency! (as usual with inheritance)
     –

         there is no <version>LATEST</version> or
     –
         <version>[1.0,)</version> for the parent
         if you change the parent, must update ALL children
     –


    So, avoid putting in the parent things that change
●


         your project modules versions
     –

         developer/machine-specific settings
     –

                         Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                            Javaday Roma III Edizione – 24 gennaio 2009
Suggestion




 Separate things that change
from things that stay the same

                             Bruce Eckel




         Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                            Javaday Roma III Edizione – 24 gennaio 2009
Dependency POMs

    Maven2 supports                             compile (default)
●                                           ●

    transitive                                         your libs
                                                  –
    dependencies
                                                test
                                            ●

           controlled by a
       –
                                                       junit, spring-test
                                                  –
           consistent use of the
                                                provided
           <scope> tag                      ●


                                                       servlet-api
                                                  –

                                                runtime
                                            ●

                       library                                              minimize them!
                                                       log4j
    your POM                                      –
                         POM

                                                system
                                            ●


                                                       tools.jar
                                                  –
                                 Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Issues and suggestions

    Good old encapsulation / minimize coupling
●


         minimize dependencies
     –

         minimize visibility
     –

    Can also define codeless POMs, which only
●

    contain a group of other dependencies
         declare with
     –
                  <packaging>pom</packaging>
         used with
     –
                  <dependency>...
              –
                      ● <type>pom</type>


                  </dependency>
              –

                            Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                               Javaday Roma III Edizione – 24 gennaio 2009
Dependency Management

    Several libraries are often used in many modules
●


                  commons-logging, spring, servlet-api,...
              ●



         avoid repeating their version everywhere in POMs
     –

    Apply DRY & separation of concerns
●


         which version to use in the parent/main POM
     –

                  <dependencyManagement> (artifact, group, version)
              ●



         whether to use it
     –

              <dependency> (artifact, group only) </dependency>
          ●



    Tip: <dependencyManagement> is also effective in
●

    overriding versions coming from transitive dependencies
                               Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                  Javaday Roma III Edizione – 24 gennaio 2009
Aggregation

    Multimodule projects
●


         every goal is repeated on
     –
         all modules by the reactor plugin
                    mvn clean
                –
                    mvn compile
                –
                                                 <modules >
         modules can be
     –
                                                  <module>client</module>
         children of master                       <module>s erver</module>
                                                  <module>tes t</module>
                but not necessarily              </modules >
            ●




                            module
     main POM
                             POM



                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
Issues and suggestions

    Issue: modules are referenced by folder name
●


         beware when checking out or renaming
     –

    Issue: IDE plugin support is not perfect
●


         m2eclipse requires manual refresh of dependencies
     –
         after configuration changes
                also, different classpaths in eclipse and maven when
            ●

                  opening a multimodule project as a single project
         netbeans only supports separate modules
     –

    Risk: pom proliferation (think of maintenance)
●


         mvn modules vs SVN modules
     –

                             Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                Javaday Roma III Edizione – 24 gennaio 2009
Suggestion




          Common Reuse Principle

Package together what is used/reused togehter

                             Robert C. Martin




                 Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                    Javaday Roma III Edizione – 24 gennaio 2009
Tip: create a β€œMaster” POM

    A β€œcomponent list” POM
●


         does not have its own code or settings
     –

         just an index of all modules to be built
     –

         it is NOT the parent of the modules
     –

    Example: the main spring pom which triggers the
●

    build of
         spring-core
     –

         spring-mvc
     –

         spring-test
     –

         ...
     –
                          Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                             Javaday Roma III Edizione – 24 gennaio 2009
Make it easy to create
                                                new projects

    Define an archetype
●


         a customizable template for creating a kind of
     –
         projects (e.g. a web application)
                defines POMs, project structure
            ●



    Simple setup with
●


                    mvn archetype:create-from-project
                –

         customize with resource filtering
     –

                ${property} references in the archetype
            ●




    Use http://appfuse.org
●


         library of pre-assembled archetypes
     –

                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
Part 3




Automate the entire build




      Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                         Javaday Roma III Edizione – 24 gennaio 2009
Automate the entire build

    Build means much more than compile!
●


    Avoid manual steps!
●


            copy, rename, deploy to a test server...
        –

            pass configuration information
        –

    Automatically process resources
●


        copy and filter configuration files, CSS, HTML, properties
    –

    Share resources across projects
●


            package them as jar/zip
        –

            reuse them in a war project with jar/zip/war overlays
        –

                    http://maven.apache.org/plugins/maven-war-plugin/overlays.html
                ●



                                   Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Assembly plugin

    Creates zips/jars containing any kind of resource
●


         project sources
     –

         common files
     –

                XSDs
            ●


              ● html/CSS


              ● templates


         http://maven.apache.org/plugins/maven-assembly-plugin
     –




                           Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                              Javaday Roma III Edizione – 24 gennaio 2009
Preview and test webapps
                                  with the Jetty plugin

    Run a webapp directly from source folders
●


                  mvn jetty:run
              –

    Advantages
●


         very fast
     –

         resource changes are visible without restart
     –

         automatic redeploy after code changes
     –

         http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin
     –

    Now a mvn glassfish:run goal is also available
●


         full JEE 5.0 support
     –

         https://maven-glassfish-plugin.dev.java.net/
     –


                            Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                               Javaday Roma III Edizione – 24 gennaio 2009
Automate deployment

    Deploy to an application server with cargo
●


         can even download, install and run a full Jboss
     –
         instance for testing purposes
         http://cargo.codehaus.org/
     –



    Write custom ssh-based scripts using the ssh/scp
●

    ant tasks within the maven-antrun-plugin
         transfer files to test servers
     –

         launch administration scripts
     –



                           Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                              Javaday Roma III Edizione – 24 gennaio 2009
Integrate with the IDE

    E.g. Eclipse plugin (m2eclipse)
●


         http://m2eclipse.sonatype.com
     –




                        Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                           Javaday Roma III Edizione – 24 gennaio 2009
Use a group repository

    Why your own?
●


    Within a Team
●


         deploy and share your project artifacts
     –

                so that other developers do not have to rebuild them
            ●



         β€œmavenize” external jars which miss a POM
     –

         centrally configure and control which repositories
     –
         and artifacts are used
         cache dependencies
     –

                available when internet connection breaks
            ●


                faster download times
            ●




                             Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                Javaday Roma III Edizione – 24 gennaio 2009
Sonatype Nexus repository

    Powerful web-based console
●


         and REST API
     –

    Lightweight
●


    Easily upload artifacts via HTTP
●


    Quickly search for jars
●


         with the included index
     –


    Download from http://nexus.sonatype.org/
●


         unzip and run!
     –

                          Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                             Javaday Roma III Edizione – 24 gennaio 2009
settings.xml: Mirror definition
    Team repository in addition to central
●


                  <repository>
              –
                       ● <id> set </id>

                       ● <url> http://server:8080/repository </url>


                  </repository>
              –

    Team repository as a mirror of central (or others)
●


                  <mirror>
              –
                       ● <id> central </id>

                       ● <url> http://server:8080/repository</url>

                       ● <mirrorOf> central </mirrorOf>


                  </mirror>
              –

    Team repository as the only one
●


                  <mirror>
              –
                       ● <id> ... </id> <url> ... </url>

                       ● <mirrorOf> * </mirrorOf>


                  </mirror>
              –

                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
Part 4




Troubleshooting




  Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                     Javaday Roma III Edizione – 24 gennaio 2009
Build troubleshooting


    Verify POM structure
●


                 mvn validate
             –

    Verify actually used dependencies
●


                 mvn dependency:tree
             –
                     ● -Dinclude=spring



    Verify the full POM
●


                 mvn help:effective-pom
             –

         m2eclipse plugin
     –

    Moreover,
●


         keep a consistent naming scheme to prevent typos
     –

                           Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                              Javaday Roma III Edizione – 24 gennaio 2009
Debug/Log

    Run mvn with
●


                    -e (print Exception stacktraces)
                –
                    -X (print debug info)
                –

    POM information can be accessed at runtime!
●


         META-INF/<group>/<artifact>/pom.properties
     –

                groupId
            ●


                artifactId                  R es ource[] res ources = applicationC ontext
            ●
                                            .g etR es ources (quot; clas s path*:M ETA-INF/mavenquot;+
                version                                                 quot; /**/pom.properties quot; );
            ●


         META-INF/../pom.xml                   for (R es ource r : res ources ) {
     –
                                                 Properties p = new Properties ();
                                                 p.load(r.g etInputS tream());
                full POM info
            ●
                                                     artifact = p.g etProperty(quot; artifactIdquot; );
                                                         vers ion = p.g etProperty(quot; vers ionquot; );
                                                  }


                                Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                     Javaday Roma III Edizione – 24 gennaio 2009
Add a timestamp to your builds

    Automatically define a timestamp property
●


          use it in resources or test properties
      –
                  <plugin>
              –
                       ● <groupId>org.codehaus.mojo</groupId>

                       ● <artifactId>buildnumber-maven-

                         plugin</artifactId>
                       ● <executions> ... </executions>

                       ● <configuration>


                           <format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
                       ●


                           <items>
                       ●


                             <item>timestamp</item>
                       ●


                           </items>
                       ●

                       ● </configuration>


                  </plugin>
    http://mojo.codehaus.org/buildnumber-maven-plugin
●




                             Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                Javaday Roma III Edizione – 24 gennaio 2009
Part 5




Keep the build fast




   Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                      Javaday Roma III Edizione – 24 gennaio 2009
Keep the build fast

    Ideally, zero-time build
●


         http://blog.carbonfive.com/2008/09/java/make-the-
     –
         things-you-do-often-fast-and-easy
    The more often a task is performed, the more its
●

    optimization improves developer productivity
         save time for actual project work
     –


    Run maven on the latest JDK
●


         benefit from JDK 1.6 fast startup times/optimizations
     –



                         Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                            Javaday Roma III Edizione – 24 gennaio 2009
Eclipse compiler

    Faster than JDK's javac
●


         also provides more warnings (unused variables, generics
     –
         misuse...)
                    <plugin>
              –

                        <artifactId>maven-compiler-plugin</artifactId>
              –

                        <configuration>
              –

                          <compilerId>eclipse</compilerId>
              –

                        </configuration>
              –

                        <dependencies>
              –

                          <dependency>
              –

                           <groupId>org.codehaus.plexus</groupId>
                     ●


                          <artifactId>plexus-compiler-eclipse</artifactId>
              –

                            <version>1.5.2</version>
              –

                          </dependency>
              –

                        </dependencies>
              –

                      </plugin>
              –


                            Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                               Javaday Roma III Edizione – 24 gennaio 2009
Unit test vs integration tests

    Run unit tests often
●


         must not take half an hour! or else developers will
     –
         just skip them
                    -Dmaven.test.skip=true
                –

    Separate unit tests from integration tests
●


         unit tests in every project/module
     –

                fast
            ●


                run at every build (within mvn install)
            ●



         integration and acceptance tests in dedicated
     –
         module
                run after major changes, and/or on build servers
            ●


                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
Remove useless build elements

    POM, plugin and dependency list keeps growing
●


    Periodically review the POM
●


         Remove unused dependencies
     –

                copying them around means more slow disk accesses
            ●


                mvn dependency:analyze
            ●



         Remove unused plugins
     –

                move them to optionally-activated profiles
            ●




                             Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                Javaday Roma III Edizione – 24 gennaio 2009
Speed-up day-to-day tasks

    Define a default goal
●


                    <defaultGoal>compile</defaultGoal>
                –

            then just run
        –
                    mvn
                –

    Use the right goal
●


        avoid a full mvn install if you just need a mvn test
    –

    Define shell aliases for common tasks
●


    Use a CI server that reads and reuses mvn
●

    configuration such as hudson
            https://hudson.dev.java.net
        –

                              Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                 Javaday Roma III Edizione – 24 gennaio 2009
Incrementally build large
                                      multimodule projects

    Reactor plugin
●


         http://maven.apache.org/plugins/maven-reactor-plugin/
     –

         manages dependencies and build order
     –

                 resume a build from the last failed module
             ●


                     mvn reactor:resume
                 –

                 build a project and all its dependencies
             ●


                     mvn reactor:make
                 –

                 build all modules which have an SVN status of changed
             ●


                     mvn reactor:make-scm-changes
                 –




                               Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                  Javaday Roma III Edizione – 24 gennaio 2009
References

    Maven official site
●


         http://maven.apache.org
     –

    Best online book
●


         Maven 2 – The Definitive Guide
     –

         http://books.sonatype.com/maven-book
     –

    JavaWorld articles
●


         Introduction to maven2
     –

                 http://www.javaworld.com/javaworld/jw-12-2005/jw-1205-maven.html
             ●


         POM
     –

                 http://www.javaworld.com/javaworld/jw-05-2006/jw-0529-maven.html
             ●




                                  Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                     Javaday Roma III Edizione – 24 gennaio 2009
Thanks for your attention!

    Learn more at
●


         http://www.carlobonamico.com/blog
     –

         http://juggenova.net
     –

                  presentations, demos, code samples
              ●



    Play with the samples
●


         http://juggenova.net/code-samples/
     –

    Contact me at
●


         carlo.bonamico@gmail.com
     –

    Related reading: Continuous Integration with Hudson
●


         http://www.slideshare.net/carlo.bonamico/continuous-integration-with-hudson
     –



                                  Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova
                                                      Javaday Roma III Edizione – 24 gennaio 2009

More Related Content

Viewers also liked

Importance of antenatal care
Importance of antenatal careImportance of antenatal care
Importance of antenatal careAbir Chowdhury
Β 
The Future of Work
The Future of WorkThe Future of Work
The Future of WorkAchievers
Β 
The Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing ContentThe Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing ContentNeil Patel
Β 
Plate tectonics slides re
Plate tectonics slides   rePlate tectonics slides   re
Plate tectonics slides reltanigawa
Β 
Tweak Your Resume
Tweak Your ResumeTweak Your Resume
Tweak Your ResumeChiara Ojeda
Β 
BCG Matrix of Engro foods
BCG Matrix of Engro foodsBCG Matrix of Engro foods
BCG Matrix of Engro foodsMutahir Bilal
Β 
Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017Techsauce Media
Β 
Mri brain anatomy Dr Muhammad Bin Zulfiqar
Mri brain anatomy Dr Muhammad Bin ZulfiqarMri brain anatomy Dr Muhammad Bin Zulfiqar
Mri brain anatomy Dr Muhammad Bin ZulfiqarDr. Muhammad Bin Zulfiqar
Β 
Aranya Community Housing
Aranya Community HousingAranya Community Housing
Aranya Community HousingKhushboo Sood
Β 
5000 Sat Words With Definitions
5000 Sat Words With Definitions5000 Sat Words With Definitions
5000 Sat Words With DefinitionsBrent Daigle, Ph.D.
Β 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086John Cutajar
Β 
Sales management By Rajiv P. Kumar (Buddhist)
Sales management By Rajiv P. Kumar (Buddhist)Sales management By Rajiv P. Kumar (Buddhist)
Sales management By Rajiv P. Kumar (Buddhist)Dr. Rajiv P. Kumar
Β 
61 Beautiful & Inspirational Timeline Cover on Facebook
61 Beautiful & Inspirational Timeline Cover on Facebook61 Beautiful & Inspirational Timeline Cover on Facebook
61 Beautiful & Inspirational Timeline Cover on FacebookConsonaute
Β 
4. heredity and evolution
4. heredity and evolution4. heredity and evolution
4. heredity and evolutionAbhay Goyal
Β 
Engaging Learners with Technology
Engaging Learners with TechnologyEngaging Learners with Technology
Engaging Learners with TechnologyDean Shareski
Β 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingContent Marketing Institute
Β 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...SlideShare
Β 
BUSINESS QUIZ -Round 1
 BUSINESS QUIZ -Round 1 BUSINESS QUIZ -Round 1
BUSINESS QUIZ -Round 1pradeep acharya
Β 
Fmcg training modules-bfg
Fmcg training modules-bfgFmcg training modules-bfg
Fmcg training modules-bfgRomy Cagampan
Β 
The New Multiscreen World By Google
The New Multiscreen World By GoogleThe New Multiscreen World By Google
The New Multiscreen World By Googleservicesmobiles.fr
Β 

Viewers also liked (20)

Importance of antenatal care
Importance of antenatal careImportance of antenatal care
Importance of antenatal care
Β 
The Future of Work
The Future of WorkThe Future of Work
The Future of Work
Β 
The Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing ContentThe Ultimate Guide to Creating Visually Appealing Content
The Ultimate Guide to Creating Visually Appealing Content
Β 
Plate tectonics slides re
Plate tectonics slides   rePlate tectonics slides   re
Plate tectonics slides re
Β 
Tweak Your Resume
Tweak Your ResumeTweak Your Resume
Tweak Your Resume
Β 
BCG Matrix of Engro foods
BCG Matrix of Engro foodsBCG Matrix of Engro foods
BCG Matrix of Engro foods
Β 
Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017Thai tech startup ecosystem report 2017
Thai tech startup ecosystem report 2017
Β 
Mri brain anatomy Dr Muhammad Bin Zulfiqar
Mri brain anatomy Dr Muhammad Bin ZulfiqarMri brain anatomy Dr Muhammad Bin Zulfiqar
Mri brain anatomy Dr Muhammad Bin Zulfiqar
Β 
Aranya Community Housing
Aranya Community HousingAranya Community Housing
Aranya Community Housing
Β 
5000 Sat Words With Definitions
5000 Sat Words With Definitions5000 Sat Words With Definitions
5000 Sat Words With Definitions
Β 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
Β 
Sales management By Rajiv P. Kumar (Buddhist)
Sales management By Rajiv P. Kumar (Buddhist)Sales management By Rajiv P. Kumar (Buddhist)
Sales management By Rajiv P. Kumar (Buddhist)
Β 
61 Beautiful & Inspirational Timeline Cover on Facebook
61 Beautiful & Inspirational Timeline Cover on Facebook61 Beautiful & Inspirational Timeline Cover on Facebook
61 Beautiful & Inspirational Timeline Cover on Facebook
Β 
4. heredity and evolution
4. heredity and evolution4. heredity and evolution
4. heredity and evolution
Β 
Engaging Learners with Technology
Engaging Learners with TechnologyEngaging Learners with Technology
Engaging Learners with Technology
Β 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
Β 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
Β 
BUSINESS QUIZ -Round 1
 BUSINESS QUIZ -Round 1 BUSINESS QUIZ -Round 1
BUSINESS QUIZ -Round 1
Β 
Fmcg training modules-bfg
Fmcg training modules-bfgFmcg training modules-bfg
Fmcg training modules-bfg
Β 
The New Multiscreen World By Google
The New Multiscreen World By GoogleThe New Multiscreen World By Google
The New Multiscreen World By Google
Β 

Similar to Maven 2 in the real world

JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederChristoph Pickl
Β 
Groovy Maven Builds
Groovy Maven BuildsGroovy Maven Builds
Groovy Maven BuildsEvgeny Goldin
Β 
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxCoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxHervΓ© Boutemy
Β 
The Maven2 Revolution
The Maven2 RevolutionThe Maven2 Revolution
The Maven2 Revolutionelliando dias
Β 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)zerok
Β 
GWT Overview And Feature Preview - SV Web JUG - June 16 2009
GWT Overview And Feature Preview - SV Web JUG -  June 16 2009GWT Overview And Feature Preview - SV Web JUG -  June 16 2009
GWT Overview And Feature Preview - SV Web JUG - June 16 2009Fred Sauer
Β 
symfony: Simplify your professional web development with PHP (Symfony PHP Que...
symfony: Simplify your professional web development with PHP (Symfony PHP Que...symfony: Simplify your professional web development with PHP (Symfony PHP Que...
symfony: Simplify your professional web development with PHP (Symfony PHP Que...Fabien Potencier
Β 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with DjangoRoger Barnes
Β 
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
Β 
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
Β 
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)Fabien Potencier
Β 
Ordina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - MavenOrdina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - MavenBert Koorengevel
Β 
PL/SQL Development
PL/SQL DevelopmentPL/SQL Development
PL/SQL DevelopmentThanh Nguyen
Β 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)Fabien Potencier
Β 
Lausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - MavenLausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - MavenArnaud HΓ©ritier
Β 
symfony: Open-Source Enterprise Framework
symfony: Open-Source Enterprise Frameworksymfony: Open-Source Enterprise Framework
symfony: Open-Source Enterprise FrameworkFabien Potencier
Β 
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
Β 

Similar to Maven 2 in the real world (20)

JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael Greifeneder
Β 
Groovy Maven Builds
Groovy Maven BuildsGroovy Maven Builds
Groovy Maven Builds
Β 
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxCoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
Β 
The Maven2 Revolution
The Maven2 RevolutionThe Maven2 Revolution
The Maven2 Revolution
Β 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)
Β 
GWT Overview And Feature Preview - SV Web JUG - June 16 2009
GWT Overview And Feature Preview - SV Web JUG -  June 16 2009GWT Overview And Feature Preview - SV Web JUG -  June 16 2009
GWT Overview And Feature Preview - SV Web JUG - June 16 2009
Β 
symfony: Simplify your professional web development with PHP (Symfony PHP Que...
symfony: Simplify your professional web development with PHP (Symfony PHP Que...symfony: Simplify your professional web development with PHP (Symfony PHP Que...
symfony: Simplify your professional web development with PHP (Symfony PHP Que...
Β 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with Django
Β 
Developing Software That Matters I
Developing Software That Matters IDeveloping Software That Matters I
Developing Software That Matters I
Β 
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
Β 
Geneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenGeneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - Maven
Β 
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
Β 
Ordina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - MavenOrdina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - Maven
Β 
PL/SQL Development
PL/SQL DevelopmentPL/SQL Development
PL/SQL Development
Β 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Β 
Maven
MavenMaven
Maven
Β 
Lausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - MavenLausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - Maven
Β 
Maven
MavenMaven
Maven
Β 
symfony: Open-Source Enterprise Framework
symfony: Open-Source Enterprise Frameworksymfony: Open-Source Enterprise Framework
symfony: Open-Source Enterprise Framework
Β 
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
Β 

More from Carlo Bonamico

Build Your Own Angular Component Library
Build Your Own Angular Component LibraryBuild Your Own Angular Component Library
Build Your Own Angular Component LibraryCarlo Bonamico
Β 
Angular Rebooted: Components Everywhere
Angular Rebooted: Components EverywhereAngular Rebooted: Components Everywhere
Angular Rebooted: Components EverywhereCarlo Bonamico
Β 
Continuous Security: Zap security bugs now Codemotion-2015
Continuous Security: Zap security bugs now Codemotion-2015Continuous Security: Zap security bugs now Codemotion-2015
Continuous Security: Zap security bugs now Codemotion-2015Carlo Bonamico
Β 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application Carlo Bonamico
Β 
Web Application Security Reloaded for the HTML5 era
Web Application Security Reloaded for the HTML5 eraWeb Application Security Reloaded for the HTML5 era
Web Application Security Reloaded for the HTML5 eraCarlo Bonamico
Β 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0Carlo Bonamico
Β 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCCarlo Bonamico
Β 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014Carlo Bonamico
Β 
Mobile HTML5 websites and Hybrid Apps with AngularJS
Mobile HTML5 websites and Hybrid Apps with AngularJSMobile HTML5 websites and Hybrid Apps with AngularJS
Mobile HTML5 websites and Hybrid Apps with AngularJSCarlo Bonamico
Β 
AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013
AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013
AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013Carlo Bonamico
Β 
Infrastructure as Data with Ansible for easier Continuous Delivery
Infrastructure as Data with Ansible for easier Continuous DeliveryInfrastructure as Data with Ansible for easier Continuous Delivery
Infrastructure as Data with Ansible for easier Continuous DeliveryCarlo Bonamico
Β 
Infrastructure as Data with Ansible
Infrastructure as Data with AnsibleInfrastructure as Data with Ansible
Infrastructure as Data with AnsibleCarlo Bonamico
Β 
Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...
Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...
Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...Carlo Bonamico
Β 
Nasa World Wind For Java (by Fabrizio Giudici)
Nasa World Wind For Java (by Fabrizio Giudici)Nasa World Wind For Java (by Fabrizio Giudici)
Nasa World Wind For Java (by Fabrizio Giudici)Carlo Bonamico
Β 
Continuous Integration With Hudson (and Jenkins)
Continuous Integration With Hudson (and Jenkins)Continuous Integration With Hudson (and Jenkins)
Continuous Integration With Hudson (and Jenkins)Carlo Bonamico
Β 
Build Automation Tips
Build Automation TipsBuild Automation Tips
Build Automation TipsCarlo Bonamico
Β 

More from Carlo Bonamico (16)

Build Your Own Angular Component Library
Build Your Own Angular Component LibraryBuild Your Own Angular Component Library
Build Your Own Angular Component Library
Β 
Angular Rebooted: Components Everywhere
Angular Rebooted: Components EverywhereAngular Rebooted: Components Everywhere
Angular Rebooted: Components Everywhere
Β 
Continuous Security: Zap security bugs now Codemotion-2015
Continuous Security: Zap security bugs now Codemotion-2015Continuous Security: Zap security bugs now Codemotion-2015
Continuous Security: Zap security bugs now Codemotion-2015
Β 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application
Β 
Web Application Security Reloaded for the HTML5 era
Web Application Security Reloaded for the HTML5 eraWeb Application Security Reloaded for the HTML5 era
Web Application Security Reloaded for the HTML5 era
Β 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Β 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
Β 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
Β 
Mobile HTML5 websites and Hybrid Apps with AngularJS
Mobile HTML5 websites and Hybrid Apps with AngularJSMobile HTML5 websites and Hybrid Apps with AngularJS
Mobile HTML5 websites and Hybrid Apps with AngularJS
Β 
AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013
AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013
AngularJS: How to code today with tomorrow tools - Codemotion Milan 2013
Β 
Infrastructure as Data with Ansible for easier Continuous Delivery
Infrastructure as Data with Ansible for easier Continuous DeliveryInfrastructure as Data with Ansible for easier Continuous Delivery
Infrastructure as Data with Ansible for easier Continuous Delivery
Β 
Infrastructure as Data with Ansible
Infrastructure as Data with AnsibleInfrastructure as Data with Ansible
Infrastructure as Data with Ansible
Β 
Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...
Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...
Is my Web Application secure? OWASP Top Ten Security Risks and Beyond...
Β 
Nasa World Wind For Java (by Fabrizio Giudici)
Nasa World Wind For Java (by Fabrizio Giudici)Nasa World Wind For Java (by Fabrizio Giudici)
Nasa World Wind For Java (by Fabrizio Giudici)
Β 
Continuous Integration With Hudson (and Jenkins)
Continuous Integration With Hudson (and Jenkins)Continuous Integration With Hudson (and Jenkins)
Continuous Integration With Hudson (and Jenkins)
Β 
Build Automation Tips
Build Automation TipsBuild Automation Tips
Build Automation Tips
Β 

Recently uploaded

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
Β 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
Β 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Β 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
Β 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
Β 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
Β 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
Β 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Β 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
Β 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
Β 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
Β 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
Β 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
Β 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
Β 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Β 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
Β 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
Β 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
Β 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
Β 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
Β 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
Β 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Β 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Β 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Β 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Β 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Β 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Β 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Β 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Β 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Β 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
Β 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
Β 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
Β 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Β 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Β 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
Β 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Β 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Β 

Maven 2 in the real world

  • 1. Object Oriented and beyond Maven 2 in the real world Carlo Bonamico carlo.bonamico@gmail.com JUG Genova Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 2. Maven2: love it or hate it? Widespread build platform ● used by many open source and commercial projects – PROs ● automatic dependency management – good tool/IDE support – automate the entire build life cycle – highly configurable also... – lots of tutorials CONs on simple cases, ● less documentation on complex builds highly configurable :-) – too much XML... – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 3. Presentation goals Maven can be your friend (and save lots of time!) ● if you – learn it and understand it ● use it in the right way ● My talk is about how to maximize usefulness and ● efficiency while minimizing complexity & overhead – Sharing real world experience ● in designing and managing the build process for – several large projects (>20 modules, >100 kLoc) Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 4. Part 1 Maven2 in 5 minutes Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 5. Maven2 in 5 minutes Maven is a modular automation system built ● around 4 main elements repository POM Maven Plugins src input: project src/resources + POM – output: tested and packaged artifact – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 6. Maven in 5': the POM The Project Object Model describes ● project coordinates – groupId: net.juggenova artifactId: sample project type – version: 1.0 packaging (JAR, WAR, EAR, POM) ● source structure – build phases – standard + custom ● dependencies – plugins – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 7. Maven in 5': build lifecycle Default life cycle Every goal implies all ● ● the previous ones validate – generate-sources – mvn compile – process-resources – actually executes – compile – validate – test-compile – generate-sources – test – process-resource – package – compile – integration-test – verify – Stand-alone goals ● install – deploy – mvn scm:update – (some skipped for clarity) – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 8. Maven in 5': Dependency Management Dependencies ● include all external libraries and files needed to – completely assemble the output JARs, WARs, ZIPs, POMs ● are versioned – can be transitive – e.g. include just spring, get commons-logging ● automatically Conflict resolution mechanism ● determines the version to be used when a jar is – included multiple times Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 9. Maven in 5': repositories Maven repository ● a structured store containing artifacts (JAR, WAR, ZIP...) – Maven uses at leas two ● local repository – on your PC – central repository – http://repo1.maven.org/maven2/ – Three types of repositories ● local repository plain filesystem folder – ${user.home}/ folder served by HTTP daemon – .m2/repository populated via SCP/FTP/WEBDAV ● full β€œintelligent” repository (with indexing, search, cache, ...) – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 10. From code to repo (and back) deploy install remote repository local repository package central resolve repository Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 11. Part 2 Effective maven2 Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 12. Getting the most out of Maven Good old sw engineering principles still apply! ● Don't repeat yourself ● things the DRY principle – always change in a project reduce time, effort, maintenance ● minimize the impact of changes ● Separate concerns ● Automate as much as possible ● Use the right tools (plugins & repositories) ● Keep the build fast ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 13. How to minimize XML Exploit the three main POM relationships ● inheritance, aggregation, dependency – This is a valid (and working) maven POM ● <project xmlns=quot;...quot; xmlns:xsi=quot;...quot; – xsi:schemaLocation=quot;...quot;> ● <modelVersion>4.0.0</modelVersion> ● <groupId>net.juggenova.sample</groupId> ● <artifactId>minimal</artifactId> ● <version>1.0</version> </project> – How can this work? ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 14. The Super POM Implicitely, all POMs inherit from the Super POM ● see http://maven.apache.org/pom.html – Defines Super ● POM standard directory structure – default plugins & repo – your where it is? inside mvn jars POM – how to check it? – mvn help:effective-pom – Convention over Configuration ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 15. The Super-POM <repos itories > <repos itory> <id>central</id> <name>Maven R epos itory S witchboard</name> <url>http://repo1.maven.org /maven2</url> </repos itory> </repos itories > <build> <s ourceDirectory>s rc/main/java</s ourceDirectory> <tes tS ourceDirectory>s rc/tes t/java</tes tS ourceDirectory> <outputDirectory>targ et/clas s es </outputDirectory> ... <res ources > <res ource> <directory>s rc/main/res ources </directory> </res ource> </res ources > <tes tR es ources >...</tes tR es ources > Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 16. The Super-POM <plug inManag ement> <plug ins > <plug in> <artifactId>maven-as s embly-plug in</artifactId> <vers ion>2.2-beta-1</vers ion> </plug in> <plug in> <artifactId>maven-compiler-plug in</artifactId> <vers ion>2.0.2</vers ion> </plug in> ... </plug ins > </plug inManag ement> </build> Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 17. Parent POM: make you own Create a POM defining your project conventions ● and tools additional resource directories – default plugin configuration – e.g. custom configuration for maven-compiler-plugin ● standard libraries – e.g. default spring version with ● <dependencyManagement> – repositories and deployment config – e.g. your company repository with ● <distributionManagement> – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 18. net.juggenova.sample:parent <build> <s ourceDirectory>java/s rc</s ourceDirectory> ... <plug inManag ement> <plug ins > <plug in> <g roupId>org .apache.maven.plug ins </g roupId> <artifactId>maven-compiler-plug in</artifactId> <config uration> <s ource>1.6</s ource> <targ et>1.6</targ et> </config uration> </plug in> <plug in> <artifactId>maven-s urefire-plug in</artifactId> <config uration>...</config uration> </plug in> </plug ins > Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 19. Parent POM: use it Reference the parent at the beginning of a POM ● <parent> – ● <artifactId>parent</artifactId> ● <groupId>net.juggenova.sample</groupId> ● <version>1.1</version> ● <relativePath>../parent</relativePath> </parent> – Useful ● if you have many similar projects/components – to separate responsibilities between senior and – junior developers to encapsulate company-wide settings – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 20. Issues and suggestions Main issue: children must reference parent ● version explicitely strong dependency! (as usual with inheritance) – there is no <version>LATEST</version> or – <version>[1.0,)</version> for the parent if you change the parent, must update ALL children – So, avoid putting in the parent things that change ● your project modules versions – developer/machine-specific settings – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 21. Suggestion Separate things that change from things that stay the same Bruce Eckel Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 22. Dependency POMs Maven2 supports compile (default) ● ● transitive your libs – dependencies test ● controlled by a – junit, spring-test – consistent use of the provided <scope> tag ● servlet-api – runtime ● library minimize them! log4j your POM – POM system ● tools.jar – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 23. Issues and suggestions Good old encapsulation / minimize coupling ● minimize dependencies – minimize visibility – Can also define codeless POMs, which only ● contain a group of other dependencies declare with – <packaging>pom</packaging> used with – <dependency>... – ● <type>pom</type> </dependency> – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 24. Dependency Management Several libraries are often used in many modules ● commons-logging, spring, servlet-api,... ● avoid repeating their version everywhere in POMs – Apply DRY & separation of concerns ● which version to use in the parent/main POM – <dependencyManagement> (artifact, group, version) ● whether to use it – <dependency> (artifact, group only) </dependency> ● Tip: <dependencyManagement> is also effective in ● overriding versions coming from transitive dependencies Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 25. Aggregation Multimodule projects ● every goal is repeated on – all modules by the reactor plugin mvn clean – mvn compile – <modules > modules can be – <module>client</module> children of master <module>s erver</module> <module>tes t</module> but not necessarily </modules > ● module main POM POM Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 26. Issues and suggestions Issue: modules are referenced by folder name ● beware when checking out or renaming – Issue: IDE plugin support is not perfect ● m2eclipse requires manual refresh of dependencies – after configuration changes also, different classpaths in eclipse and maven when ● opening a multimodule project as a single project netbeans only supports separate modules – Risk: pom proliferation (think of maintenance) ● mvn modules vs SVN modules – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 27. Suggestion Common Reuse Principle Package together what is used/reused togehter Robert C. Martin Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 28. Tip: create a β€œMaster” POM A β€œcomponent list” POM ● does not have its own code or settings – just an index of all modules to be built – it is NOT the parent of the modules – Example: the main spring pom which triggers the ● build of spring-core – spring-mvc – spring-test – ... – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 29. Make it easy to create new projects Define an archetype ● a customizable template for creating a kind of – projects (e.g. a web application) defines POMs, project structure ● Simple setup with ● mvn archetype:create-from-project – customize with resource filtering – ${property} references in the archetype ● Use http://appfuse.org ● library of pre-assembled archetypes – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 30. Part 3 Automate the entire build Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 31. Automate the entire build Build means much more than compile! ● Avoid manual steps! ● copy, rename, deploy to a test server... – pass configuration information – Automatically process resources ● copy and filter configuration files, CSS, HTML, properties – Share resources across projects ● package them as jar/zip – reuse them in a war project with jar/zip/war overlays – http://maven.apache.org/plugins/maven-war-plugin/overlays.html ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 32. Assembly plugin Creates zips/jars containing any kind of resource ● project sources – common files – XSDs ● ● html/CSS ● templates http://maven.apache.org/plugins/maven-assembly-plugin – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 33. Preview and test webapps with the Jetty plugin Run a webapp directly from source folders ● mvn jetty:run – Advantages ● very fast – resource changes are visible without restart – automatic redeploy after code changes – http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin – Now a mvn glassfish:run goal is also available ● full JEE 5.0 support – https://maven-glassfish-plugin.dev.java.net/ – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 34. Automate deployment Deploy to an application server with cargo ● can even download, install and run a full Jboss – instance for testing purposes http://cargo.codehaus.org/ – Write custom ssh-based scripts using the ssh/scp ● ant tasks within the maven-antrun-plugin transfer files to test servers – launch administration scripts – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 35. Integrate with the IDE E.g. Eclipse plugin (m2eclipse) ● http://m2eclipse.sonatype.com – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 36. Use a group repository Why your own? ● Within a Team ● deploy and share your project artifacts – so that other developers do not have to rebuild them ● β€œmavenize” external jars which miss a POM – centrally configure and control which repositories – and artifacts are used cache dependencies – available when internet connection breaks ● faster download times ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 37. Sonatype Nexus repository Powerful web-based console ● and REST API – Lightweight ● Easily upload artifacts via HTTP ● Quickly search for jars ● with the included index – Download from http://nexus.sonatype.org/ ● unzip and run! – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 38. settings.xml: Mirror definition Team repository in addition to central ● <repository> – ● <id> set </id> ● <url> http://server:8080/repository </url> </repository> – Team repository as a mirror of central (or others) ● <mirror> – ● <id> central </id> ● <url> http://server:8080/repository</url> ● <mirrorOf> central </mirrorOf> </mirror> – Team repository as the only one ● <mirror> – ● <id> ... </id> <url> ... </url> ● <mirrorOf> * </mirrorOf> </mirror> – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 39. Part 4 Troubleshooting Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 40. Build troubleshooting Verify POM structure ● mvn validate – Verify actually used dependencies ● mvn dependency:tree – ● -Dinclude=spring Verify the full POM ● mvn help:effective-pom – m2eclipse plugin – Moreover, ● keep a consistent naming scheme to prevent typos – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 41. Debug/Log Run mvn with ● -e (print Exception stacktraces) – -X (print debug info) – POM information can be accessed at runtime! ● META-INF/<group>/<artifact>/pom.properties – groupId ● artifactId R es ource[] res ources = applicationC ontext ● .g etR es ources (quot; clas s path*:M ETA-INF/mavenquot;+ version quot; /**/pom.properties quot; ); ● META-INF/../pom.xml for (R es ource r : res ources ) { – Properties p = new Properties (); p.load(r.g etInputS tream()); full POM info ● artifact = p.g etProperty(quot; artifactIdquot; ); vers ion = p.g etProperty(quot; vers ionquot; ); } Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 42. Add a timestamp to your builds Automatically define a timestamp property ● use it in resources or test properties – <plugin> – ● <groupId>org.codehaus.mojo</groupId> ● <artifactId>buildnumber-maven- plugin</artifactId> ● <executions> ... </executions> ● <configuration> <format>{0,date,yyyy-MM-dd HH:mm:ss}</format> ● <items> ● <item>timestamp</item> ● </items> ● ● </configuration> </plugin> http://mojo.codehaus.org/buildnumber-maven-plugin ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 43. Part 5 Keep the build fast Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 44. Keep the build fast Ideally, zero-time build ● http://blog.carbonfive.com/2008/09/java/make-the- – things-you-do-often-fast-and-easy The more often a task is performed, the more its ● optimization improves developer productivity save time for actual project work – Run maven on the latest JDK ● benefit from JDK 1.6 fast startup times/optimizations – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 45. Eclipse compiler Faster than JDK's javac ● also provides more warnings (unused variables, generics – misuse...) <plugin> – <artifactId>maven-compiler-plugin</artifactId> – <configuration> – <compilerId>eclipse</compilerId> – </configuration> – <dependencies> – <dependency> – <groupId>org.codehaus.plexus</groupId> ● <artifactId>plexus-compiler-eclipse</artifactId> – <version>1.5.2</version> – </dependency> – </dependencies> – </plugin> – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 46. Unit test vs integration tests Run unit tests often ● must not take half an hour! or else developers will – just skip them -Dmaven.test.skip=true – Separate unit tests from integration tests ● unit tests in every project/module – fast ● run at every build (within mvn install) ● integration and acceptance tests in dedicated – module run after major changes, and/or on build servers ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 47. Remove useless build elements POM, plugin and dependency list keeps growing ● Periodically review the POM ● Remove unused dependencies – copying them around means more slow disk accesses ● mvn dependency:analyze ● Remove unused plugins – move them to optionally-activated profiles ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 48. Speed-up day-to-day tasks Define a default goal ● <defaultGoal>compile</defaultGoal> – then just run – mvn – Use the right goal ● avoid a full mvn install if you just need a mvn test – Define shell aliases for common tasks ● Use a CI server that reads and reuses mvn ● configuration such as hudson https://hudson.dev.java.net – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 49. Incrementally build large multimodule projects Reactor plugin ● http://maven.apache.org/plugins/maven-reactor-plugin/ – manages dependencies and build order – resume a build from the last failed module ● mvn reactor:resume – build a project and all its dependencies ● mvn reactor:make – build all modules which have an SVN status of changed ● mvn reactor:make-scm-changes – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 50. References Maven official site ● http://maven.apache.org – Best online book ● Maven 2 – The Definitive Guide – http://books.sonatype.com/maven-book – JavaWorld articles ● Introduction to maven2 – http://www.javaworld.com/javaworld/jw-12-2005/jw-1205-maven.html ● POM – http://www.javaworld.com/javaworld/jw-05-2006/jw-0529-maven.html ● Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009
  • 51. Thanks for your attention! Learn more at ● http://www.carlobonamico.com/blog – http://juggenova.net – presentations, demos, code samples ● Play with the samples ● http://juggenova.net/code-samples/ – Contact me at ● carlo.bonamico@gmail.com – Related reading: Continuous Integration with Hudson ● http://www.slideshare.net/carlo.bonamico/continuous-integration-with-hudson – Carlo Bonamico - carlo.bonamico@gmail.com – JUG Genova Javaday Roma III Edizione – 24 gennaio 2009