Java Build Tooling  Apache Maven Olivier Lamy   |   @olamy VP Apache Maven, ASF Member
Agenda●   Who am I: Introduction●   What is the Apache Software Foundation●   Java build tools evolution●   Apache Maven● ...
/me●   Olivier Lamy (@olamy ) (twitter.com/olamy)●   https://www.slideshare.net/olamy / http://olamy.blogspot.fr●   Apache...
What is The ASF●   Membership-based corporation; Non-profit US    501(c)3 Charity●   Directors, officers all unpaid volunt...
Apache Org Chart                              Nominate, elect   Members                              Directors annually   ...
Apache Mission: What●   Provide open source software to the public free    of charge    –   “Apache aims to provide a prag...
Apache License●   Apache projects use the Apache License 2.0●   Pragmatic and permissive    –   Maximum freedom for users●...
Apache Projects●   Over 100 code-producing community driven    projects    –   50+ Podlings in Incubation●   “Apache Proje...
Apache Projects●   Industry standards:    –   Apache HTTP Server (original project from the        foundation)    –   Apac...
Java Build Tools Evolution
Javac                Basic command line toolToo many parameters to set for classpath, sourcepath,           annotations pr...
Java Build Evolution●   We dont only build one or two classes.●   Use of external dependencies●   Complex packaging (not o...
Build Evolution : Ant“Apache Ant is a Java-based build tool. In theory,it is kind of like Make, but without Makes wrinkles...
Build Evolution : AntWhy create another tool when make, gnumakealready exist?They all have some limitationsThey are more S...
Build Evolution : AntAnt has Java Class like extensionsUse of XML instead of Shell ScriptsEach task is taken care of by cr...
Build Evolution : AntBuild.xml:●   Similar to makefile but an XML file●   Its the default file where ant will look for wha...
Build Evolution : AntSimple build file<project name=”sample” default=”hello> <target name=”hello”>  <echo message=”Hello f...
Build Evolution : AntDownload from http://ant.apache.org/bindownload.cgiSample project: https://github.com/olamy/hello-wor...
Build Evolution : Ant    ant -p: list all targets●   ant compile●   ant run-tests●   ant package
Build Evolution : AntSo you have to define everythinginclude jars in your source tree/scmeach ant build is a rewrite of an...
Build Evolution: MavenDownload fromhttp://maven.apache.org/download.htmlM2_HOME= path to maven home installPATH=$M2_HOME/b...
Build Evolution: Mavenpom.xml is smallSame project: mvn test, mvn package
Build Evolution : Ant●   Ant doesnt have formal conventions like a common      project directory structure, you have to te...
Build Evolution: MavenMaven has conventions, it already knew where yoursource code was because you followed the convention...
Apache Maven: HistoryMaven, a Yiddish word meaning accumulator ofknowledge, was originally started as an attemptto simplif...
Apache Maven: History                   Maven 1.0Introduced dependency mechanism and remoterepositoriesPlugin mechanismLim...
Apache Maven: History                   Maven 2.0Full rewrite using plain Java and IoC containerPlexus (fork of dead Apach...
Apache Maven: History                   Maven 3.0Move to Guice IoC (with a layer to mimic Plexusapi).More extensible~99% b...
Apache MavenGoals:●    Making the build process easy●    Providing a uniform build system●    Providing quality project in...
Apache Maven Definition●   Apache Maven is a software project management and    comprehension tool.●   Based on the concep...
Apache Maven DefinitionConvention over Configuration !!
Apache Maven Conventions●   1 project = 1 artifact (jar,war,ear, etc …)Standardized :●   directories layout●   project des...
Apache Maven POM●   POM: Project Object Model    –   Project Coordinates    –   Dependencies    –   Build settings    –   ...
Apache Maven Coordinate              groupId:artifactId:version<groupId>org.olamy.maven.course</groupId><artifactId>hello-...
Apache Maven Dependencies<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <!-...
Apache Maven Dependencies                             ScopeCompile (by default) : Required to build and run theapplication...
Apache Maven Dependencies                        Transitiviy●   Project A needs project B●   Project B needs project C    ...
Apache Maven Dependencies                 Transitiviy: exclude<dependency> <groupId>org.apache.cxf</groupId> <artifactId>c...
Apache Maven Dependencies             Nearest version approach●   Project A needs project B●   Project B needs project C 1...
Apache Maven Dependencies                   Artifact repository●   Download by default from:    http://repo.maven.apache.o...
Apache Maven Dependencies                  Remote repository●   http(s) transport●   Url format: ${groupId}/${artifactId}/...
Apache Maven Dependencies             Remote repositorydependency: org.apache.maven.plugins:maven-compiler-plugin:3.0http:...
Apache Maven Dependencies                  Central repository    contains most of the open source projects    Stats: http:...
Apache Maven Version        Project and dependency versionsTwo different version variantsSNAPSHOT version●   The version n...
Apache Maven Version                   SNAPSHOT versionsMaven allows the configuration of an update policy. Theupdate poli...
Apache Maven Version                      RANGE versionsFrom ... to …Maven automatically searches for the correspondingver...
Apache Maven Archetype         Easy start with archetype     More than 600 projects type template !           mvn archetyp...
Apache Maven Archetype         Start with Tomcat Archetype●   mvn install●   Import in an IDE
Apache Maven Lifecycle          Lifecycle is a sequence of plugin              executions called phases●   Full reference:...
Apache Maven Lifecycle         A project has a packaging type●   <packaging/> default is jar (war, ear etc..)●   With a pa...
Apache Maven Lifecycle        Add a plugin execution to your lifecycle    <plugin>     <groupId>org.apache.tomcat.maven</g...
Multi Modules projects             Build multiple projects         SOC: Separation Of Concern●   Module with an api●   N m...
Multi Modules projects        Parent packaging pom<modules> <module>module-api</module> <module>module-api-tck</module> <m...
Multi Modules projects              InheritenceDefine common values in parent pom → noneed to repeat common valuesDependen...
Multi Modules projects                     Inheritence    All projects inherit from super pom which    defined some values...
Multi Modules projects          Dependency Management                          parent pom<dependencyManagement><dependenci...
Multi Modules projects          Dependency Management                          child poms<dependencies> <dependency>  <gro...
Multi Modules projects               Plugin Management                         parent pom<pluginManagement> <plugins>  <pl...
Multi Modules projects                Plugin Management                          child poms Nothing version, <configuratio...
Multi Modules projects            child poms: configuration inheritence override.    Elements under configuration have att...
Plugins   Each plugin execution is Java classby default each packaging comes with plugins attached to                    l...
Plugins              Override default         <pluginManagement> section●   All used plugins must have a version     ●   D...
Plugins                      Configuration<plugin> <configuration> <foo>bar</foo> <directory>${project.build.directory}</d...
Plugins                           Write your own    A maven project with <packaging>maven-plugin</packaging>    class exte...
Plugins                                How ?       Maven will read metadata available in annotations from your    class: a...
Plugins                                hack    Generate a mojo from archetype.●   Default with doclet●   With annotations:...
Plugins                        Parametersusers parameters@Parameter( property = "tomcat.delegate", defaultValue ="true" )p...
Plugins            Maven Parameters Injected@Parameter( defaultValue = "${project.packaging}", required =true, readonly = ...
Plugins                  Component Injectedyour own@Component( role = MavenFileFilter.class, hint = "default" )private Mav...
Plugins                        AdvancedInvoke a plugin directly which need previous phases executiontomcat7:run will start...
Maven                 Artifacts Distribution<distributionManagement> <repository>  <id>apache.releases.https</id>  <name>A...
Maven Settings   Your local settings in ~/.m2/settings.xmlyour credentials to deploy to a remote server  <server>   <id>ap...
Maven Settings   Your local settings in ~/.m2/settings.xmlMirrors for corporate env:<mirror> <name>archiva-repository</nam...
Maven Site                  mvn site:site → target/site    Build a web site with your documentations.    Formats:●   Apt (...
Maven Site                 Descriptor src/site/site.xml●   menu entries    <project name="">     <body>      <menu name="M...
Maven Site                             customize●   skin     <skin>      <groupId>org.apache.maven.skins</groupId>      <a...
Maven Site                           Add reports●   Reporting section with maven plugins     <reporting>      <plugins>   ...
Maven Site                   Instrumental reports●   Findbugs    <reporting>     <plugins>      <plugin>       <groupId>or...
Maven Site                               Deploy●   Protocols: ftp, scp, webdav, scm      <site>       <id>id for your sett...
Apache MavenComplementary tooling
Apache Maven Repository          Deploying to share your project●   An open source project ? So ask to deploy it to centra...
Apache Maven Repository                Install Archiva locally●   Download from    http://archiva.apache.org/download.html...
Apache Maven Repository           Proxy to external repositories●   Some organisations doesnt allow external access●   Art...
Continuous Integration       Detect issues as soon as possible●   Code will be rebuild on any scm change●   New artifact s...
Continuous Integration●   Bamboo from Atlassian (paying product)●   TeamCity from Jetbrains (paying product)●   Continuum ...
Continuous Integration                             Jenkins●   http://jenkins-ci.org●   Easy to install/use: java -jar jenk...
Continuous Inspection                            Sonar●   Dashboard with various metrics●   Aggregator of existing Maven r...
References●   http://maven.apache.org●   http://archiva.apache.org●   http://jenkins-ci.org●   http://sonar.codehaus.org● ...
Thanks/Merci   Questions ?olamy@apache.org
Upcoming SlideShare
Loading in...5
×

Maven university-course

1,068

Published on

course on build tools maven in a Frenc university

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,068
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
44
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Put the item people are least familiar with, but which is really most important, first. While the Apache Projects provide all the code, it&apos;s the Foundation and the Apache Way that enable them to do that – independently, and for the long-term.
  • Note that currently 100% of my time on Apache work is as an unpaid volunteer; my IBM job is completely unrelated (both technically and organizationally).
  • The most important thing to realize on this slide: while the Foundation provides a home for over 100 projects, each of those projects is really an independent community of developers and users.
  • Fundamentally, the organization is pretty simple. The Membership elects a Board of Nine Directors annually. The Board sets overall policy and provides oversight for all operations. Note especially that officers and PMCs report directly to the board. The President and VP, Infrastructure manage day-to-day operations – but only of the infrastrucutre itself, not of our projects. The most important thing to realize from this picture is (click) that everything to the left of the page only provides organizational oversight. All technical decisions are made on the right hand half – within the PMCs and projects individually.
  • It&apos;s really that simple. The Foundation&apos;s purpose is to serve as a stable and independent home for it&apos;s projects. The Foundation should only be there to handle the stuff coders don&apos;t want to do or aren&apos;t good at handling; everything else – and especially all technical decisions – are made by the coders in PMCs and projects.
  • All Apache software should be useable under our license. This ensures maximum freedom for users. This also ensures that software released with our license is available to the public.
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • This is a great quote from today&apos;s press release by the ASF. We also have about a dozen past projects, and a number of other, non-code projects to assist with operations. Conferences committee, Community Development, and others are tasked to manage various operations like events and educating new contributors (Legal, Brand Management, Fundraising, and Marketing &amp; Publicity are all officers, not PMCs)
  • Maven university-course

    1. 1. Java Build Tooling Apache Maven Olivier Lamy | @olamy VP Apache Maven, ASF Member
    2. 2. Agenda● Who am I: Introduction● What is the Apache Software Foundation● Java build tools evolution● Apache Maven● Extend Apache Maven● Complementary Tooling
    3. 3. /me● Olivier Lamy (@olamy ) (twitter.com/olamy)● https://www.slideshare.net/olamy / http://olamy.blogspot.fr● Apache Software Foundation – Member – VP, Maven – PMCs: Maven, Archiva, Tomcat, Sqoop, DirectMemory, Kalumet – Commiter: Commons● Jenkins etc.. (add bugs in various opensource projects)● Also a OpenSource Architect at Talend
    4. 4. What is The ASF● Membership-based corporation; Non-profit US 501(c)3 Charity● Directors, officers all unpaid volunteers● Paid contractors: sysadmins, press officer● Broad-based Membership of individuals ensures independence➔ Collection of Apache project communities
    5. 5. Apache Org Chart Nominate, elect Members Directors annually Organizational ~400 Oversight Technical Board of Oversight Nominate, elect 9 Directors new members Create & update upon Appoint officers PMC request Report monthly Report quarterly PMCs Officers 100++ ~10Define organizational &legal policies Committers Nominate, elect Vote for new committers project releases ~3,000 Write project code
    6. 6. Apache Mission: What● Provide open source software to the public free of charge – “Apache aims to provide a pragmatic, non-technical framework to its projects.” - Justin Erenkrantz● Let coders code; Foundation exists to do rest● Community over code
    7. 7. Apache License● Apache projects use the Apache License 2.0● Pragmatic and permissive – Maximum freedom for users● Includes patent grant● Easily and frequently used by other groups
    8. 8. Apache Projects● Over 100 code-producing community driven projects – 50+ Podlings in Incubation● “Apache Projects include millions of lines of code overseen by an all-volunteer community across six continents. Apache technologies power more than half the Internet, petabytes of data, teraflops of operations, billions of objects, and enhance the lives of countless users and developers.”
    9. 9. Apache Projects● Industry standards: – Apache HTTP Server (original project from the foundation) – Apache Tomcat (Servlet container) – Apache Hadoop – Apache Commons * – Apache Subversion – Etc http://projects.apache.org/indexes/alpha.html
    10. 10. Java Build Tools Evolution
    11. 11. Javac Basic command line toolToo many parameters to set for classpath, sourcepath, annotations processors etc.. Use it for hello world only
    12. 12. Java Build Evolution● We dont only build one or two classes.● Use of external dependencies● Complex packaging (not only jars)● Running tests (complex tests)● Interaction with external tools (issues trackers, scm, ci servers)
    13. 13. Build Evolution : Ant“Apache Ant is a Java-based build tool. In theory,it is kind of like Make, but without Makes wrinkles” -Apache Ant Website
    14. 14. Build Evolution : AntWhy create another tool when make, gnumakealready exist?They all have some limitationsThey are more Shell BasedLimits you to one kind of OS
    15. 15. Build Evolution : AntAnt has Java Class like extensionsUse of XML instead of Shell ScriptsEach task is taken care of by creating its objectStandardizedPlatform Independent
    16. 16. Build Evolution : AntBuild.xml:● Similar to makefile but an XML file● Its the default file where ant will look for what to build, how to build● Has projects, targets, tasks
    17. 17. Build Evolution : AntSimple build file<project name=”sample” default=”hello> <target name=”hello”> <echo message=”Hello from ant”/> </target></project>
    18. 18. Build Evolution : AntDownload from http://ant.apache.org/bindownload.cgiSample project: https://github.com/olamy/hello-worldgit clone https://github.com/olamy/hello-world.gitorhttps://github.com/olamy/hello-world/archive/master.zip
    19. 19. Build Evolution : Ant ant -p: list all targets● ant compile● ant run-tests● ant package
    20. 20. Build Evolution : AntSo you have to define everythinginclude jars in your source tree/scmeach ant build is a rewrite of an other one
    21. 21. Build Evolution: MavenDownload fromhttp://maven.apache.org/download.htmlM2_HOME= path to maven home installPATH=$M2_HOME/bin:$PATH
    22. 22. Build Evolution: Mavenpom.xml is smallSame project: mvn test, mvn package
    23. 23. Build Evolution : Ant● Ant doesnt have formal conventions like a common project directory structure, you have to tell Ant exactly where to find the source and where to put the output. Informal conventions have emerged over time, but they havent been codified into the product.● Ant is procedural, you have to tell Ant exactly what to do and when to do it. You had to tell it to compile, then copy, then compress.● Ant doesnt have a lifecycle, you had to define goals and goal dependencies. You had to attach a sequence of tasks to each goal manually.
    24. 24. Build Evolution: MavenMaven has conventions, it already knew where yoursource code was because you followed the convention. Itput the bytecode in target/classes, and it produced a JARfile in target.Maven is declarative. All you had to do was create apom.xml file and put your source in the default directory.Maven took care of the rest.Maven has a lifecycle, which you invoked when youexecuted mvn install. This command told Maven toexecute a series of sequence steps until it reached thelifecycle. Maven executed a number of default plugingoals which did things like compile and create a JAR.
    25. 25. Apache Maven: HistoryMaven, a Yiddish word meaning accumulator ofknowledge, was originally started as an attemptto simplify the build processes in the Jakartaprojects.There were several projects each with their ownAnt build files that were all slightly different andJARs were checked into CVS. We wanted astandard way to build the projects, a cleardefinition of what the project consisted of, an easyway to publish project information and a way toshare JARs across several projects.
    26. 26. Apache Maven: History Maven 1.0Introduced dependency mechanism and remoterepositoriesPlugin mechanismLimited to a wrapper on the top of Ant using antand jelly scriplet
    27. 27. Apache Maven: History Maven 2.0Full rewrite using plain Java and IoC containerPlexus (fork of dead Apache Avalon)New Pom syntax: migration from maven 1.0 needrewrite.
    28. 28. Apache Maven: History Maven 3.0Move to Guice IoC (with a layer to mimic Plexusapi).More extensible~99% backward compatible.
    29. 29. Apache MavenGoals:● Making the build process easy● Providing a uniform build system● Providing quality project information● Providing guidelines for best practice development● Allowing transparent migration to new features
    30. 30. Apache Maven 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 projects build, binaries, reporting and documentation from a central piece of information.● Apache Maven is a command line tool with some IDE integrations.
    31. 31. Apache Maven DefinitionConvention over Configuration !!
    32. 32. Apache Maven Conventions● 1 project = 1 artifact (jar,war,ear, etc …)Standardized :● directories layout● project descriptor (POM)● build lifecycle
    33. 33. Apache Maven POM● POM: Project Object Model – Project Coordinates – Dependencies – Build settings – Description – Distribution mode
    34. 34. Apache Maven Coordinate groupId:artifactId:version<groupId>org.olamy.maven.course</groupId><artifactId>hello-world</artifactId><version>1.0-SNAPSHOT</version>
    35. 35. Apache Maven Dependencies<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <!--optionnals --> <scope>test</scope> <classifier>sources</sources></dependency>
    36. 36. Apache Maven Dependencies ScopeCompile (by default) : Required to build and run theapplicationRuntime : not required to build the application but needed atruntime (Ex : taglibs)Provided : required to build the application but not needed atruntime (provided by the container) (Ex : Servlet API, DriverSGBD, …)Test : required to build and launch tests but not needed by theapplication itself to build and run (Ex : Junit,) TestNG, DbUnit,…System : local library with absolute path
    37. 37. Apache Maven Dependencies Transitiviy● Project A needs project B● Project B needs project C So Maven detect project A needs project C
    38. 38. Apache Maven Dependencies Transitiviy: exclude<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-bundle-jaxrs</artifactId> <exclusions> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> </exclusion> </exclusions></dependency>
    39. 39. Apache Maven Dependencies Nearest version approach● Project A needs project B● Project B needs project C 1.1● Project A needs project C 1.0 Maven detect project A needs project C 1.0
    40. 40. Apache Maven Dependencies Artifact repository● Download by default from: http://repo.maven.apache.org/maven2/● Cached locally to ${user.home}/repository – Used by maven – Used by your projects – Produced by your projects
    41. 41. Apache Maven Dependencies Remote repository● http(s) transport● Url format: ${groupId}/${artifactId}/${artifactId}-$ {version}(-${classifier}).${type} groupId: dot replaced by slash
    42. 42. Apache Maven Dependencies Remote repositorydependency: org.apache.maven.plugins:maven-compiler-plugin:3.0http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.0/maven-compiler-plugin-3.0.jar
    43. 43. Apache Maven Dependencies Central repository contains most of the open source projects Stats: http://search.maven.org/#stats● Total number of artifacts indexed (GAV): 402,355● Total number of unique artifacts indexed (GA): 48,632● Current size of repository on disk: 650,388 MB
    44. 44. Apache Maven Version Project and dependency versionsTwo different version variantsSNAPSHOT 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 repositoriesRELEASE version● The version number doesn’t end with –SNAPSHOT● Binaries won’t change
    45. 45. Apache Maven Version SNAPSHOT versionsMaven allows the configuration of an update policy. Theupdate policy defines the recurrence of checks if there is anew SNAPSHOT version available on the remote repository :● always● daily (by default)● interval:X (a given period in minutes)● neverMust not be used in a released projectThe release can thus also be changed
    46. 46. Apache Maven Version RANGE versionsFrom ... to …Maven automatically searches for the correspondingversion (using the update policy for releasedartifacts)To use with caution● Risk of non reproducibility of the build● Risk of side effects on your projects and projects depending on them.
    47. 47. Apache Maven Archetype Easy start with archetype More than 600 projects type template ! mvn archetype:generateChoose one (you can apply filtering on the name)Start to code/enhance the generated template
    48. 48. Apache Maven Archetype Start with Tomcat Archetype● mvn install● Import in an IDE
    49. 49. Apache Maven Lifecycle Lifecycle is a sequence of plugin executions called phases● Full reference: http://maven.apache.org/guides/introduction/introducti on-to-the-lifecycle.html#Lifecycle_Reference – validate – … – compile – … – Etc...
    50. 50. Apache Maven Lifecycle A project has a packaging type● <packaging/> default is jar (war, ear etc..)● With a packaging comes a lifecycle with plugins mapping● As long as you respect standard layout maven will pack for you respecting standards
    51. 51. Apache Maven Lifecycle Add a plugin execution to your lifecycle <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <executions> <execution> <id>tomcat-run</id> <goals> <goal>run-war-only</goal> </goals> <phase>pre-integration-test</phase>●
    52. 52. Multi Modules projects Build multiple projects SOC: Separation Of Concern● Module with an api● N modules with different implementation
    53. 53. Multi Modules projects Parent packaging pom<modules> <module>module-api</module> <module>module-api-tck</module> <module>module-impl-a</module> <module>module-impl-b</module></module>
    54. 54. Multi Modules projects InheritenceDefine common values in parent pom → noneed to repeat common valuesDependency Management → dependenciesversion defined in only one place
    55. 55. Multi Modules projects Inheritence All projects inherit from super pom which defined some values:● Main sources: src/main/java● Test sources: src/test/java● Etc....
    56. 56. Multi Modules projects Dependency Management parent pom<dependencyManagement><dependencies> <dependency> <groupId>org.lamy</groupId> <artifactId>foo</artifactId> <version>1.0</version> </dependency></dependencies></dependencyManagement>
    57. 57. Multi Modules projects Dependency Management child poms<dependencies> <dependency> <groupId>org.lamy</groupId> <artifactId>foo</artifactId> <!-- version inherited from parent --> </dependency></dependencies>
    58. 58. Multi Modules projects Plugin Management parent pom<pluginManagement> <plugins> <plugin> <groupId>org.lamy</groupId> <artifactId>foo</artifactId> <version> </plugin> </plugins></pluginManagement>
    59. 59. Multi Modules projects Plugin Management child poms Nothing version, <configuration> and <executions> will beinheritedinheritance can be overridden.inheritance can be removed: <inherited>true</inherited> pluginswont be executed in child projects.
    60. 60. Multi Modules projects child poms: configuration inheritence override. Elements under configuration have attributes to control inheritance mode● combine.children=”append” (default is merge) → appen or not child content to parent content● combine.self=”override” (default is merge) → stop inheritance
    61. 61. Plugins Each plugin execution is Java classby default each packaging comes with plugins attached to lifecycle phases. For simple projects nothing to doBut you can attach new plugins and executions to lifecycle
    62. 62. Plugins Override default <pluginManagement> section● All used plugins must have a version ● Default configuration override ● Inherited in child poms
    63. 63. Plugins Configuration<plugin> <configuration> <foo>bar</foo> <directory>${project.build.directory}</directory> </configuration>xml configurationcommand line override with -Ddirectory=path
    64. 64. Plugins Write your own A maven project with <packaging>maven-plugin</packaging> class extends AbstractMojo :● Implements method execute● Some services getLog() to log as Maven do● getPluginContext(): possible to share information between plugins● Class lifecycle: initializable method when it starts (by default its a singleton class across your build)
    65. 65. Plugins How ? Maven will read metadata available in annotations from your class: a plugin descriptor will be generated and Maven execution will understand that. @Mojo( name = "foo", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )● Mvn ${groupId}:${artifactId}:${version}:foo● Dependencies to scope test will be resolved● ThreadSafe for multi thread build
    66. 66. Plugins hack Generate a mojo from archetype.● Default with doclet● With annotations: mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-plugin -DarchetypeVersion=1.2 -DarchetypeRepository= https://repository.apache.org/content/repositories/maven-090/
    67. 67. Plugins Parametersusers parameters@Parameter( property = "tomcat.delegate", defaultValue ="true" )private boolean delegate = true;<configuration> <delegate>false</delegate></configuration>Or-Dtomcat.delegate=false
    68. 68. Plugins Maven Parameters Injected@Parameter( defaultValue = "${project.packaging}", required =true, readonly = true )private String packaging;@Componentprotected MavenProject project;@Parameter( defaultValue = "${project.artifacts}", required =true, readonly = true )private Set<Artifact> dependencies;
    69. 69. Plugins Component Injectedyour own@Component( role = MavenFileFilter.class, hint = "default" )private MavenFileFilter mavenFileFilter;from Maven core@Componentprotected ArtifactResolver resolver;
    70. 70. Plugins AdvancedInvoke a plugin directly which need previous phases executiontomcat7:run will start an embeded Tomcat but need classes tobe compiled first.Fork lifecycle@Execute( phase = LifecyclePhase.PROCESS_CLASSES )will reach process-classes phase then execute your mojo.
    71. 71. Maven Artifacts Distribution<distributionManagement> <repository> <id>apache.releases.https</id> <name>Apache Release Distribution Repository</name> <url></url> </repository> <snapshotRepository> <id>apache.snapshots.https</id> <name>${distMgmtSnapshotsName}</name> <url>${distMgmtSnapshotsUrl}</url> </snapshotRepository></distributionManagement>
    72. 72. Maven Settings Your local settings in ~/.m2/settings.xmlyour credentials to deploy to a remote server <server> <id>apache.snapshots.https</id> <username>uid</username> <password>password</password> </server>
    73. 73. Maven Settings Your local settings in ~/.m2/settings.xmlMirrors for corporate env:<mirror> <name>archiva-repository</name> <mirrorOf>central</mirrorOf> (or * ) <id>archiva-asf-mirror</id> <url>https://archiva-repository.apache.org/archiva/repository/public</url></mirror>
    74. 74. Maven Site mvn site:site → target/site Build a web site with your documentations. Formats:● Apt (files in src/site/apt) (http://maven.apache.org/doxia/references/apt-format.html)● Xdoc (files in src/site/xdoc) (http://maven.apache.org/doxia/references/xdoc-format.html)● Markdown (files in src/site/markdown) no real specs for that :-)
    75. 75. Maven Site Descriptor src/site/site.xml● menu entries <project name=""> <body> <menu name="Menu"> <item name="About" href="index.html"/> <item name="TODO" href="todo.html"/> </menu> </project>
    76. 76. Maven Site customize● skin <skin> <groupId>org.apache.maven.skins</groupId> <artifactId>maven-fluido-skin</artifactId> <version>1.3.0</version> </skin>
    77. 77. Maven Site Add reports● Reporting section with maven plugins <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.6</version> </plugin> </plugins>
    78. 78. Maven Site Instrumental reports● Findbugs <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>2.5.2</version> </plugin> </plugins>
    79. 79. Maven Site Deploy● Protocols: ftp, scp, webdav, scm <site> <id>id for your settings.xml</id> <url>dav:url</url> </distributionManagement>
    80. 80. Apache MavenComplementary tooling
    81. 81. Apache Maven Repository Deploying to share your project● An open source project ? So ask to deploy it to central● Use a repository manager to share inside your entity/compay – Apache Archiva: http://archiva.apache.org – Nexus: http://www.sonatype.org/nexus/ – Artifactory: http://www.jfrog.com
    82. 82. Apache Maven Repository Install Archiva locally● Download from http://archiva.apache.org/download.html● Archiva 1.4-M3 Standalone new UI● Unzip● cd bin● archiva console
    83. 83. Apache Maven Repository Proxy to external repositories● Some organisations doesnt allow external access● Artifacts will be cached not access to external repositories● Control repositories you are using <mirror> <mirrorOf>*</mirror> </mirror>
    84. 84. Continuous Integration Detect issues as soon as possible● Code will be rebuild on any scm change● New artifact snapshots deployed for others
    85. 85. Continuous Integration● Bamboo from Atlassian (paying product)● TeamCity from Jetbrains (paying product)● Continuum from Apache● CruiseControl● Hudson/Jenkins We will talk about Jenkins :-)
    86. 86. Continuous Integration Jenkins● http://jenkins-ci.org● Easy to install/use: java -jar jenkins.war● No need for external tools (database etc..)● Configuration stored on the file system
    87. 87. Continuous Inspection Sonar● Dashboard with various metrics● Aggregator of existing Maven reports (and more)● http://sonar.codehaus.org● Easy install● Daily run in Jenkins● Tests it
    88. 88. References● http://maven.apache.org● http://archiva.apache.org● http://jenkins-ci.org● http://sonar.codehaus.org● http://fr.slideshare.net/olamy/maven-universitycourse
    89. 89. Thanks/Merci Questions ?olamy@apache.org
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×