Apache MavenMarch 3rd, 2010Arnaud HéritiereXo PlatformSoftware Factory Manager
Arnaud HéritierSoftware Factory ManagereXo platform In charge of tools and methodsCommitter since 2004 and member of the Project Management CommitteeCoauthor of « Apache Maven » published by Pearson (in French)Contact me :http://aheritier.netTwitter : @aheritierSkype : aheritier
AgendaApache Maven
OverviewDefinitionHistoryConceptsConventionsPOMReactor and ModulesInheritanceArtifact RepositoryDependencyVersionProfilesBuildLifecycle And PluginsWhy did we choose Maven for eXo platform ?Maven, the project choiceMaven, the corporate choice
Maven’s EcosystemRepository ManagersQuality ManagementTests AutomationQuality Metrics ReportsProject ReportsSonarContinuous IntegrationIDEEclipseIdea IntelliJNetbeans
Good & Bad PracticesK.I.S.S.Project OrganizationPOMDevelopment
UsecasesSecure your credentialsBuild a part of your project using reactor optionsAutomate your release process (at least the technical part)Setup a global mirror
Back to the futureMaven 2.xMaven 3.xCommunityCompetitorsOverviewApache Maven
DefinitionApache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM) Maven can manage a project's build, binaries, reporting and documentation from a central piece of information.
HistoryInitiated in 2001 by Jason Van Zyl in Alexandria, an Apache Jakarta project,Moved to Turbine few months after,Became a Top Level Project in 2003.Maven 2.0 released in September 2005Maven 3.0 … coming soon !!!
ConceptsApache Maven
Conventions1 project = 1 artifact (pom, jar, war, ear, …)Standardized project descriptor (POM)build lifecycledirectories layout*.java to compile in src/[main|test]/java*.xml, *.properties needed in classpath and to bundle in archive in src/[main|test]/resourcestarget directory for generated stuffs (sources, classes, …)…
POMAn XML file (pom.xml)DescribingProject identificationProject versionProject descriptionBuild settingsDependencies…<?xml version="1.0" encoding="UTF-8"?><project> <modelVersion>4.0.0</modelVersion> <groupId>net.aheritier.samples</groupId> <artifactId>simple-webapp</artifactId> <version>1.1-SNAPSHOT</version> <packaging>war</packaging> <name>Simple webapp</name> <inceptionYear>2007</inceptionYear> <dependencies>  <dependency>   <groupId>org.springframework</groupId>   <artifactId>spring-struts</artifactId>   <version>2.0.2</version>  </dependency>  ... </dependencies></project>
ReactorSplit your project in sub-modulesMaven computes the build order from dependencies between sub-modules.Modules have to be defined in the POMNo auto-discovery for performance reasons<project>  ...  <modules>    <module>moduleA</module>    <module>moduleB</module>    <module>moduleC</module>    <module>moduleD</module>    <module>moduleE</module>      <module>moduleF</module>  </modules>  ...</project>
InheritanceShare settings between projects/modulesBy default the parent project is supposed to be in the parent directory (../)<parent>  <groupId>net.aheritier.sample</groupId>  <artifactId>my-parent</artifactId>  <version>1.0.0-SNAPSHOT<version></parent>
InheritanceUse a technical inheritance to organize sub-modulesUse assembly to package batchsInsert README in all artifactsUse clirr to validate backward compatibility
Artifact RepositoryBy default :A central repositoryhttp://repo1.maven.org/maven2Several dozen of Gb of OSS librariesA local repository${user.home}/.m2/repositoryAll artifactsUsed by maven and its pluginsUsed by your projects (dependencies)Produced by your projects
Artifact RepositoryBy default Maven downloads artifacts required by the project or itself from centralDownloaded artifacts are stored in the local repositoryUsed to store :Project’s binariesProject’s dependenciesMaven and plug-ins binaries
DependenciesWithout MavenWith Maven
DependenciesDeclarativesgroupId + artifactId + version (+ classifier)Type (packaging) : jar, war, pom, ear, …TransitivesLib A needs Lib BLib B needs Lib CThus Lib A needs Lib C
DependenciesScopeCompile (by default) : Required to build and run the applicationRuntime : not required to build the application but needed at runtimeEx : taglibsProvided : required to build the application but not needed at runtime (provided by the container)Ex : Servlet API, Driver SGBD, …Test : required to build and launch tests but not needed by the application itself to build and runEx : Junit, TestNG, DbUnit, …System : local library with absolute pathEx : software products
DependenciesDefine all dependencies you are usingand no more !If you have optional dependenciesPerhaps you should have optional modules insteadCleanup your dependencies withmvndependency:analyzeStudy your dependencies withmvndependency:treemvndependency:list
VersionsProject and dependency versionsTwo different version variantsSNAPSHOT versionThe version number ends with –SNAPSHOTThe project is in development Deliveries are changing over the time and are overridden   after each buildArtifacts are deployed with a timestamp on remote repositoriesRELEASE versionThe version number doesn’t end with –SNAPSHOTBinaries won’t change
Versions
VersionsAbout SNAPSHOT dependenciesMaven allows the configuration of an update policy. The update policy defines the recurrence of checks if there is a new SNAPSHOT version available on the remote repository :alwaysdaily (by default)interval:X (a given period in minutes)neverMust not be used in a released projectThey can change thus the release also The release plugin will enforce it 
VersionsRangeFrom … to … Maven automatically searches for the corresponding version (using the update policy for released artifacts)To use with cautionRisk of non reproducibility of the buildRisk of sideeffectson projects depending on yours.
VersionsUse the versions plugin to update all versions of your project and its modulesmvnversions:set –DnewVersion=A.B.C-SNAPSHOT
ProfilesAllow to modify the default behavior of Maven by overriding/adding some settingsUse mvnhelp:active-profilesto debugExplicit activation or deactivationmvn <phases or goals>   -PprofileId1,-profileId2   -P!profileId3
ProfilesactiveByDefault = If no other profile isactivated
Activation throughMaven settings<settings>  ...  <activeProfiles>    <activeProfile>profile-1</activeProfile>  </activeProfiles>  ...</settings>
ProfilesActivation based on environment variables<profiles>  <profile>    <activation>      <property>        <name>!skip-enforce</name>      </property>    </activation>    ...  </profile></profiles><profiles>  <profile>    <activation>      <property>        <name>run-its</name>        <value>true</value>      </property>    </activation>    ...  </profile></profiles>
ProfilesOS / Java settings<profiles>  <profile>    <activation>      <jdk>[1.3,1.6)</jdk>    </activation>    ...  </profile></profiles><profiles>  <profile>    <activation>      <os>      <name>Windows XP</name>      <family>Windows</family>      <arch>x86</arch>      <version>5.1.2600</version>    </os>  </activation>  ...  </profile></profiles>
ProfilesActivation on present or missing files<profiles>  <profile>    <activation>      <file>        <missing>${project.build.directory}/generated-sources/axistools/wsdl2java/</missing>      </file>    </activation>    ...  </profile></profiles>
BuildLifecycle And PluginsPlugin based architecture for a great extensibilityStandardized lifecycle to build all types of archetypes
BuildLifecycle And Plugins
Build Lifecycle And PluginsMany pluginsPackagingReportingIDE integrationMiscellaneous tools integrationMany locationsmaven.apache.orgmojo.codehaus.orgcode.google.com…The SWF Team provides a set of coherent and tested plugins using our eXo parent POM
Maven or not Maven, that is the question !Apache Maven
Maven, the project’s choiceApplication’s architectureThe project has the freedom to divide the application in modulesMaven doesn’t limit the evolution of the application architectureDependencies managementDeclarative : Maven automatically downloads them and builds the classpathTransitive : We define only what the module needs itself
Maven, the project’s choiceCentralizes and automates all development facets (build, tests, releases)One thing it cannot do for you : to develop BuildsTestsPackagesDeploysDocumentsChecks and reports about the quality of developments
Maven, the corporate’s choiceWidely adopted and knownMany developersDevelopments are standardizedDecrease of costsReuse of knowledgeReuse of configuration fragmentsReuse of process and code fragmentsProduct qualityimprovementReports and monitoring
ecosystemApache Maven
Maven’s ecosystemMavenaloneisnothingYou can integrate it with many toolsA large set of plug-ins is already availableYou can define your own plug-ins
repository managerSApache Maven
Repository ManagersSeveral productsSonatype Nexus (replaced Proximity)JfrogArtifactoryApache ArchivaBasic servicesSearch artifactsBrowse repositoriesProxy external repositoriesHost internal repositoriesSecurity
Secure your buildsDeploy a repository manager to proxy externals repositories to :Avoid external network outagesAvoid external repository unavailabilitiesTo reduce your company’s external network usageTo increase the speed of artifact downloadsAdditional services offered by such servers :Artifacts procurement to filter what is coming from the outsideStaging repository to validate your release before deploying it
Nexus at eXo for productivity
Nexus at eXo for collaborationDeploy 3rd Party ArtifactsCollaborate with Internal RepositoriesDistribute to the community with Public RepositoriesDistribute to customers with Private Repositories
Nexus at eXo for qualityEase the Burden on Central and others remote repositoriesGain Predictability and ScalabilityControl and Audit Dependencies and ReleasesStage releases
Quality managementApache Maven
Tests AutomationUse automated tests as often as you canMany tools are available through MavenJUnit, TestNG – unit tests, Selenium, Canoo – web GUI test,Fitnesse, Greenpepper – functional tests,SoapUI – web services testsJMeter – performances testsAnd many more frameworks are available to reply your needs
Quality MetricsExtract quality metrics from your project and monitor them :Code style (CheckStyle)Bad practices or potential bugs (PMD, FindBugs, Clirr)Tests coverage (Cobertura, Emma, Clover)…You can use blocking rulesFor example, I break the build if the upward compatibility of public APIs is brokenYou can use reportsReports are available in a web site generated by MavenOr in a quality dashboard like Sonar
Dependency Report
Sonar, a quality dashboard
Sonar, analyze your project
Sonar, Continuous Improvement ?
Continuous integrationApache Maven
Continuous IntegrationSetup a continuous integration server to :Have a neutral and unmodified environment to run your testsQuickly react when The build fails (compilation failure for example)A test failsA quality metric is badContinuously improve the quality of your project and your productivityMany productsJenkins, Hudson, Bamboo, TeamCity, Continuum, Cruisecontrol, …
Jenkins, how the weather is ?
Jenkins: build, test, check
IDEApache Maven
EclipseIntegration from maven (eclipse:eclipse)Allow many customizationsSupport many versions/variants of eclipseSupport many usages (ear …)Doesn’t support projects with “pom” packagingFew support from dev teamMany bugs in classpath managementAsynchronousYou have to regenerate and reload project each time you change a POM)
EclipseIntegration from eclipse (m2eclipse)SynchronousNice UI and services to edit POMsSupport projects with “pom” packagingDoesn’t support all usages like EAR with WTPDoesn’t support very well a large number of modulesSlow down eclipse on large projects because of a lack of support of incremental build in Maven 2.x and its plugins
Eclipse (m2eclipse)
Eclipse (m2eclipse)
Eclipse (m2eclipse)
Idea IntelliJ
Netbeans
Good & bad practicesApache Maven
KISSApache Maven
K.I.S.S.Keep It Simple, StupidStart from scratchDo not copy/paste what you find without understandingUse only what you needIt’s not because maven offers many features that you need to use themFilteringModulesProfiles…
PROJECT ORGANIZATIONGOOD & BAD PracticesApache Maven
Project bad practicesIgnore Maven conventionsExcept if your are migrating from something else and the target has to be to follow them.Except if they are not compatible with your IDEDifferent versions in sub-modulesIn that case they are standalone projects.Too many inheritance levelsIt makes the POMs maintenance more complexWhere should I set this plugin parameter ? In which parent ?
Project bad practicesHave too many modulesIs there a good reason ?Technical constraint ?Team organization ?It increases the build timeMany more artifacts to generateDependencies resolution more complexIt involves more complex developmentsMore modules to import in your IDEMore modules to update …
Project good practicesUse the default inheritance :The reactor project is also the parent of its modules.Configuration is easier :No need to redefine SCM settings, site distribution settings …
POM GOOD & BAD PracticesApache Maven
POM bad practicesDependencies :DON’T confuse dependencies and dependencyManagementPlugins :DON’T confuse plugins and pluginManagementDON’T use AntRunplugin everywhereDON’T let Maven choose plugins versions for you
POM bad practicesProfiles :DON’T create environment dependant buildsDON’T rely on dependencies coming from profiles (there is no transitive activation of profiles)Reporting and qualityDON’T activate on an existing project all reports with default configurationDON’T control formatting rules without giving settings for IDEs.DON’T put everything you find in your POM.
POM good practicesSet versions of dependencies in project parent’s dependencyManagementSet dependencies (groupId, artifactId, scope) in each module they are usedUse the dependency plugin (from apache) and versions plugin (from mojo) to analyze, cleanup and update your dependencies.
Development good & bad practicesApache Maven
Development bad practicesDON’T spend your time in the terminal,DON’T exchange libraries through emails,DON’T always use "-Dmaven.test.skip=true” DON’T manually do releases
Development good practicesKeep up-to-date your version of MavenFor example in 2.1 the time of dependencies/modules resolution decreased a lot (Initialization of a project of 150 modules passed from 8 minutes to less than 1)Use the reactor plugin (Maven < 2.1) or native reactor command line options (Maven >= 2.1) to rebuild only a subpart of your project :All modules depending on module XXXAll modules used to build XXX  Try to not use Maven features not supported by your IDE (resources filtering with the plugineclipse:eclipse)
UsecasesApache Maven
Secure your credentialsApache Maven
Secure your credentialsGenerate a private key
arnaud@leopard:~$ mvn --encrypt-master-password toto{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}
We save the private key in ~/.m2/settings-security.xml<settingssecurity>  <master>{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}</master></settingssecurity>
Secure your credentialsYou can move this key to another drive ~/.m2/settings.xml
<settingsSecurity>  <relocation>/Volumes/ArnaudUsbKey/secure/settings-security.xml</relocation></settingsSecurity>
You create an encrypted version of your server password
arnaud@mbp-arnaud:~$ mvn--encrypt-password titi{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}
You register it in your settings
<settings>  ...    <servers>      ...        <server>          <id>mon.server</id>          <username>arnaud</username>          <password>{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}</password>        </server>      ...    </servers>  ...</settings>Build a part of Your ProjectApache Maven
Using Reactor OptionsOptions added in maven 2.1Available in 2.0.x with the maven-reactor-pluginBut syntax is longerAllow to control what you want to build in your project
Using Reactor Optionsarnaud@mbp-arnaud:~$ mvn install[INFO] ------------------------------------------------[INFO] Reactor Summary:[INFO][INFO] Project ....................... SUCCESS [2.132s][INFO] ModuleA ....................... SUCCESS [5.574s][INFO] ModuleB ....................... SUCCESS [0.455s][INFO] ModuleC ....................... SUCCESS [0.396s][INFO] ModuleD ....................... SUCCESS [0.462s][INFO] ModuleE ....................... SUCCESS [0.723s][INFO] ModuleF ....................... SUCCESS [0.404s]
Builds everything from A to FUsing Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –pl moduleE,moduleB[INFO] -------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleB .................. SUCCESS [2.774s][INFO] ModuleE .................. SUCCESS [1.008s]
Builds only modules B and E
Following dependencies order
-pl --project-list: Build the specified reactor projects instead of all projectsUsing Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –pl moduleD -am[INFO] ------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleA ................. SUCCESS [4.075s][INFO] ModuleB ................. SUCCESS [0.468s][INFO] ModuleC ................. SUCCESS [0.354s][INFO] ModuleD ................. SUCCESS [0.384s]
Builds module D (-pl) and all modules it uses as dependencies
-am --also-make: If a project list is specified, also make projects that the list depends on
Usecase : Build all modules required for a war, ear, …Using Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –pl moduleD -amd[INFO] ------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleD ................. SUCCESS [4.881s][INFO] ModuleE ................. SUCCESS [0.478s][INFO] ModuleF ................. SUCCESS [0.427s]
Builds module D (-pl) and all modules which depend on it
-amd --also-make-dependents: If a project list is specified, also make projects that depend on projects on the list
Usecase : Check that a change in a module didn’t break others which are using itUsing Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –rf moduleD[INFO] ------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleD ................. SUCCESS [9.707s][INFO] ModuleE ................. SUCCESS [0.625s][INFO] ModuleF ................. SUCCESS [0.679s] [INFO] Project ................. SUCCESS [2.467s]
Restarts all the build from module D (-rf)
 -rf,--resume-from <arg> :                Resume reactor from specified project
Usecase : The build failed a 1st time in module D, you fixed it, and restart the build were it was to end it.ReleasE Your projectApache Maven
Release of a webapp in 2002Limited usage of eclipseNo WTP (Only some features in WSAD), No ability to produce WARs
Release of a webapp in 2002Many manual tasksModify settings filesPackage JARsCopy libraries (external and internal) in a « lib » directoryPackage WAR (often with a zip command)Tag the code (CVS)Send the package on the integration server using FTPDeploy the package with AS console
Release of a webapp in 2002One problem : The are always problemsError in config filesMissing dependenciesMissing fileLast minute fix which created a bugAnd many other possibilies ..How long did it take ?When everything is ok : 15 minutesWhen there’s a problem : ½ day or more
Maven Release PluginAutomates the release process from tagging sources to binaries deliveryRelease plugin main goals:Prepare : To update maven versions and information in POMs and tag the codePerform : To deploy binaries in a maven repositoryAfter that you can just automate the deployment on the AS using cargo for example.
Maven Release Plugin
Configuration and PrerequisitesProject version (must be a SNAPSHOT version)Dependencies and plugins versions mustn’t be SNAPSHOTs
Troubleshooting ReleasesCommon errorsduring release:Buildwith release profile wastestedbefore and failsLocal modificationsCurrent version is not a SNAPSHOTSNAPSHOTs in dependencies and/or pluginsMissingsome configuration (scm, distribMgt, …)Tag alreadyexistsUnable to deployproject to the RepositoryConnectionproblems
SCM configurationSCM binaries have to be in the PATHSCM credentials have to already be stored or you have to pass them in command line with :–Dusername=XXX –Dpassword=XXX<scm> <connection>scm:svn:http://svn.acme.com/myproject/trunk</connection> <developerConnection>scm:svn:https://svn.acme.com/myproject/trunk</developerConnection> <url>http://fisheye.acme.com/browse/myproject/trunk</url></scm>
Distribution ManagementWhereyouwant to uploadreleasedbinariesThe url of a repositorydedicated for yourproject/corporatemavendeliveries in yourrepository manager<project> <distributionManagement>  <repository>   <id>repository.acme.com</id>   <url>${acme.releases.repo.url}</url>  </repository> . . . </distributionManagement> . . .  <properties>  <acme.releases.repo.url>http://repo.acme.com/acme-releases</acme.releases.repo.url>  . . . </properties></project>This id willbeused in user’smaven settings (~/.m2/settings.xml)Oftenuseful to have a property to test the release process on a fakerepository, to validate a repo manager ...
Repository credentialsOne server entry isrequired per differentrepository id in distribution management of projectsIn a corporateenvironment, use a unique id for all repositorieshosted on repository managers usingsamecredentials (corporate LDAP …)<settings> ... <servers>  <server>   <id>repository.acme.com</id>   <username>aheritier</username>   <password>{ABCDEFGHIJKLMNOPQRSTUVWYZ}</password>  </server>  ... </servers> ...</settings>This id is the one defined in distributionManagement entry of the project to release
Default Release Profile in Super POMThis profile isusedwhenyougeneratebinaries of the release with “mvnrelease:perform”By default, generates sources and javadocs jars for each module.<profile> <id>release-profile</id> <activation>  <property>   <name>performRelease</name>   <value>true</value>  </property> </activation> <build>  <plugins>  ...  </plugins> </build></profile>This activation couldbeused in profiles youwant to activate in the release processConfiguration to generate sources and javadoc jars with basic setting
Custom release profile<project> ... <build>  <pluginManagement>   <plugins>    <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-release-plugin</artifactId>     <version>2.0</version>     <configuration>      <useReleaseProfile>false</useReleaseProfile>      <releaseProfiles>myreleaseprofile</releaseProfiles>     </configuration>    </plugin>   </plugins>  </pluginManagement> </build> ... <profiles>  <profile>   <id>myreleaseprofile</id>   <build>    ...   </build>  </profile> </profiles> ...</project>Don’t use the default profileUse ourcustomized profileOur customized profileCustomize the behavior of the build for a releaseTake care to test isbefore the release !!
SETUP a GLObal MirrorApache Maven
Why should we setup a global mirror ?To simplify users and projects settingsTo control where binaries are coming fromTo not rely on project’s repositoriesTo use only the corporate repository managerTo improve build performancesBy reducing the number of requests to find a missing artefact
How should we setup a global mirror ?   <setting>  <mirrors>    <mirror>      <id>global-mirror</id>      <mirrorOf>external:*</mirrorOf>      <url>http://repo.acme.com/public</url>    </mirror>  </mirrors>  <profiles>    <profile>      <id>mirror</id>      <repositories>        <repository>          <id>central</id>          <url>http://central</url>          <releases><enabled>true</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </repository>      </repositories>      <pluginRepositories>        <pluginRepository>          <id>central</id>          <url>http://central</url>          <releases><enabled>true</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </pluginRepository>      </pluginRepositories>    </profile>  </profiles>  <activeProfiles>    <activeProfile>mirror</activeProfile>  </activeProfiles></settings>    Send all requests to this urlUse « central » id to override default maven configurationEnablesnapshotsmake the profile active all the time
Back to the FutureApache Maven
productApache Maven
Apache Maven 2.0.xbugs fixLast release : 2.0.11No other release of 2.0.x in the future
Apache Maven 2.xEvolutions, new featuresSeveral important new features in 2.1 likeParallel downloadsEncrypted passwordsReactor command line optionsLast release : 2.2.1
Apache Maven 3.xDo not be afraid !!!!!Full compatibility with maven 2.x projectsOr at least at 99,99999%3.0 : October 20103.0.1 : November 20103.0.2 : January 20113.0.3 : March 2011~ every 6 weeks
Apache Maven 3.x – Why ?To build new foundations for the futureThe major part of the code was reviewed / rewrittenHow POMs are constructedHow the lifecycle is executedHow the plugin manager executesHow artifacts are resolvedHow it can be embeddedHow dependency injection is done…
Apache Maven 3.x - robustnessError & integrity reportingMuch improved error reporting where we will provide links to each identifiable problem we know of. There are currently 42 common things that can go wrong.Don't allow builds where versions come from non-project sources like local settings and CLI parametersDon't allow builds where versions come from profiles that have to be activated manuallyBackward compatibilitySeveral thousands of integration tests
Apache Maven 3.x - performancesMany optimizationsNew support of parallel builds of modulesNew incremental (partial) buildTo improve IDE integration
Apache Maven 3.x – new featuresAny-source POMIf you don’t like XML, choose another DSLVersionless parent elementsIf you don’t use versions or release plugins to automatically update themMixinsa compositional form of Maven POM configurationGlobal excludes
Apache Maven 3.xWhat it will change for maven developers ?Lifecycle extension pointsPlugin extension pointsIncremental build supportQueryable lifecycleExtensible reportingBye bye Plexus, welcome JSR 330 & Google GuiceWelldefined and documented APIs
Apache Maven 3.x – New tools mvnshA cross-platform shell dedicated to mavenTychoMaven ready for OSGI and Eclipse developments
In Apache Maven 3.0 ?A backward compatibility near to 100% for projects and pluginsA totally new implementationA greater robustness with a better reporting and more readable logsPerformances improvements and new parallel buildsA better integration for others tools like IDE or continuous integration serversNo change in current POM format
CommunityApache Maven
Users Mailing Listusers@maven.apache.orgTrafficstatisticscover a total of 2025 days.Currentsubscribers:	1936Current digest subscribers:	48Total posts(2025 days):	89687Meanposts per day:	44.29http://pulse.apache.org/Blue : Number of subscribersRed : Number of messages per day
Apache Maven Web Site
DowloadsPer month downloadshttp://people.apache.org/~vgritsenko/stats/projects/maven.html
The team60 committers,More than 30 active in 2009,Several organizations like Sonatype, deliver resources and professional support,A community less isolated : more interactions with Eclipse, Jetty,
Commit Statistics
CompetitorsApache Maven
Choose your way of thinkingConventions approachScripting approach
CompetitorsAnt + Ivy, Easy Ant, Gant, Gradle, Buildr…Script orientedYou can do what you want !Reuse many of Maven conventions (directories layout, …) and services (repositories) but without enforcing themThe risk for them : Not being able to evolve due to the too high level of customization proposed to the user. We tried on Maven 1 and it died because of that. It was impossible to create a set of tests to cover all usages.It’s like providing a framework without public API 
With scripts oriented buildsYou can have(if you have good skills)But often you have(moreover after years …)

Apache Maven - eXo VN office presentation

  • 1.
    Apache MavenMarch 3rd,2010Arnaud HéritiereXo PlatformSoftware Factory Manager
  • 2.
    Arnaud HéritierSoftware FactoryManagereXo platform In charge of tools and methodsCommitter since 2004 and member of the Project Management CommitteeCoauthor of « Apache Maven » published by Pearson (in French)Contact me :http://aheritier.netTwitter : @aheritierSkype : aheritier
  • 3.
  • 4.
    OverviewDefinitionHistoryConceptsConventionsPOMReactor and ModulesInheritanceArtifactRepositoryDependencyVersionProfilesBuildLifecycle And PluginsWhy did we choose Maven for eXo platform ?Maven, the project choiceMaven, the corporate choice
  • 5.
    Maven’s EcosystemRepository ManagersQualityManagementTests AutomationQuality Metrics ReportsProject ReportsSonarContinuous IntegrationIDEEclipseIdea IntelliJNetbeans
  • 6.
    Good & BadPracticesK.I.S.S.Project OrganizationPOMDevelopment
  • 7.
    UsecasesSecure your credentialsBuilda part of your project using reactor optionsAutomate your release process (at least the technical part)Setup a global mirror
  • 8.
    Back to thefutureMaven 2.xMaven 3.xCommunityCompetitorsOverviewApache Maven
  • 9.
    DefinitionApache Maven isa software project management and comprehension tool. Based on the concept of a project object model (POM) Maven can manage a project's build, binaries, reporting and documentation from a central piece of information.
  • 10.
    HistoryInitiated in 2001by Jason Van Zyl in Alexandria, an Apache Jakarta project,Moved to Turbine few months after,Became a Top Level Project in 2003.Maven 2.0 released in September 2005Maven 3.0 … coming soon !!!
  • 11.
  • 12.
    Conventions1 project =1 artifact (pom, jar, war, ear, …)Standardized project descriptor (POM)build lifecycledirectories layout*.java to compile in src/[main|test]/java*.xml, *.properties needed in classpath and to bundle in archive in src/[main|test]/resourcestarget directory for generated stuffs (sources, classes, …)…
  • 13.
    POMAn XML file(pom.xml)DescribingProject identificationProject versionProject descriptionBuild settingsDependencies…<?xml version="1.0" encoding="UTF-8"?><project> <modelVersion>4.0.0</modelVersion> <groupId>net.aheritier.samples</groupId> <artifactId>simple-webapp</artifactId> <version>1.1-SNAPSHOT</version> <packaging>war</packaging> <name>Simple webapp</name> <inceptionYear>2007</inceptionYear> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-struts</artifactId> <version>2.0.2</version> </dependency> ... </dependencies></project>
  • 14.
    ReactorSplit your projectin sub-modulesMaven computes the build order from dependencies between sub-modules.Modules have to be defined in the POMNo auto-discovery for performance reasons<project> ... <modules> <module>moduleA</module> <module>moduleB</module> <module>moduleC</module> <module>moduleD</module> <module>moduleE</module> <module>moduleF</module> </modules> ...</project>
  • 15.
    InheritanceShare settings betweenprojects/modulesBy default the parent project is supposed to be in the parent directory (../)<parent> <groupId>net.aheritier.sample</groupId> <artifactId>my-parent</artifactId> <version>1.0.0-SNAPSHOT<version></parent>
  • 16.
    InheritanceUse a technicalinheritance to organize sub-modulesUse assembly to package batchsInsert README in all artifactsUse clirr to validate backward compatibility
  • 17.
    Artifact RepositoryBy default:A central repositoryhttp://repo1.maven.org/maven2Several dozen of Gb of OSS librariesA local repository${user.home}/.m2/repositoryAll artifactsUsed by maven and its pluginsUsed by your projects (dependencies)Produced by your projects
  • 18.
    Artifact RepositoryBy defaultMaven downloads artifacts required by the project or itself from centralDownloaded artifacts are stored in the local repositoryUsed to store :Project’s binariesProject’s dependenciesMaven and plug-ins binaries
  • 19.
  • 20.
    DependenciesDeclarativesgroupId + artifactId+ version (+ classifier)Type (packaging) : jar, war, pom, ear, …TransitivesLib A needs Lib BLib B needs Lib CThus Lib A needs Lib C
  • 21.
    DependenciesScopeCompile (by default): Required to build and run the applicationRuntime : not required to build the application but needed at runtimeEx : taglibsProvided : required to build the application but not needed at runtime (provided by the container)Ex : Servlet API, Driver SGBD, …Test : required to build and launch tests but not needed by the application itself to build and runEx : Junit, TestNG, DbUnit, …System : local library with absolute pathEx : software products
  • 22.
    DependenciesDefine all dependenciesyou are usingand no more !If you have optional dependenciesPerhaps you should have optional modules insteadCleanup your dependencies withmvndependency:analyzeStudy your dependencies withmvndependency:treemvndependency:list
  • 23.
    VersionsProject and dependencyversionsTwo different version variantsSNAPSHOT versionThe version number ends with –SNAPSHOTThe project is in development Deliveries are changing over the time and are overridden after each buildArtifacts are deployed with a timestamp on remote repositoriesRELEASE versionThe version number doesn’t end with –SNAPSHOTBinaries won’t change
  • 24.
  • 25.
    VersionsAbout SNAPSHOT dependenciesMavenallows the configuration of an update policy. The update policy defines the recurrence of checks if there is a new SNAPSHOT version available on the remote repository :alwaysdaily (by default)interval:X (a given period in minutes)neverMust not be used in a released projectThey can change thus the release also The release plugin will enforce it 
  • 26.
    VersionsRangeFrom … to… Maven automatically searches for the corresponding version (using the update policy for released artifacts)To use with cautionRisk of non reproducibility of the buildRisk of sideeffectson projects depending on yours.
  • 27.
    VersionsUse the versionsplugin to update all versions of your project and its modulesmvnversions:set –DnewVersion=A.B.C-SNAPSHOT
  • 28.
    ProfilesAllow to modifythe default behavior of Maven by overriding/adding some settingsUse mvnhelp:active-profilesto debugExplicit activation or deactivationmvn <phases or goals> -PprofileId1,-profileId2 -P!profileId3
  • 29.
    ProfilesactiveByDefault = Ifno other profile isactivated
  • 30.
    Activation throughMaven settings<settings> ... <activeProfiles> <activeProfile>profile-1</activeProfile> </activeProfiles> ...</settings>
  • 31.
    ProfilesActivation based onenvironment variables<profiles> <profile> <activation> <property> <name>!skip-enforce</name> </property> </activation> ... </profile></profiles><profiles> <profile> <activation> <property> <name>run-its</name> <value>true</value> </property> </activation> ... </profile></profiles>
  • 32.
    ProfilesOS / Javasettings<profiles> <profile> <activation> <jdk>[1.3,1.6)</jdk> </activation> ... </profile></profiles><profiles> <profile> <activation> <os> <name>Windows XP</name> <family>Windows</family> <arch>x86</arch> <version>5.1.2600</version> </os> </activation> ... </profile></profiles>
  • 33.
    ProfilesActivation on presentor missing files<profiles> <profile> <activation> <file> <missing>${project.build.directory}/generated-sources/axistools/wsdl2java/</missing> </file> </activation> ... </profile></profiles>
  • 34.
    BuildLifecycle And PluginsPluginbased architecture for a great extensibilityStandardized lifecycle to build all types of archetypes
  • 35.
  • 36.
    Build Lifecycle AndPluginsMany pluginsPackagingReportingIDE integrationMiscellaneous tools integrationMany locationsmaven.apache.orgmojo.codehaus.orgcode.google.com…The SWF Team provides a set of coherent and tested plugins using our eXo parent POM
  • 37.
    Maven or notMaven, that is the question !Apache Maven
  • 38.
    Maven, the project’schoiceApplication’s architectureThe project has the freedom to divide the application in modulesMaven doesn’t limit the evolution of the application architectureDependencies managementDeclarative : Maven automatically downloads them and builds the classpathTransitive : We define only what the module needs itself
  • 39.
    Maven, the project’schoiceCentralizes and automates all development facets (build, tests, releases)One thing it cannot do for you : to develop BuildsTestsPackagesDeploysDocumentsChecks and reports about the quality of developments
  • 40.
    Maven, the corporate’schoiceWidely adopted and knownMany developersDevelopments are standardizedDecrease of costsReuse of knowledgeReuse of configuration fragmentsReuse of process and code fragmentsProduct qualityimprovementReports and monitoring
  • 41.
  • 42.
    Maven’s ecosystemMavenaloneisnothingYou canintegrate it with many toolsA large set of plug-ins is already availableYou can define your own plug-ins
  • 43.
  • 44.
    Repository ManagersSeveral productsSonatypeNexus (replaced Proximity)JfrogArtifactoryApache ArchivaBasic servicesSearch artifactsBrowse repositoriesProxy external repositoriesHost internal repositoriesSecurity
  • 45.
    Secure your buildsDeploya repository manager to proxy externals repositories to :Avoid external network outagesAvoid external repository unavailabilitiesTo reduce your company’s external network usageTo increase the speed of artifact downloadsAdditional services offered by such servers :Artifacts procurement to filter what is coming from the outsideStaging repository to validate your release before deploying it
  • 46.
    Nexus at eXofor productivity
  • 47.
    Nexus at eXofor collaborationDeploy 3rd Party ArtifactsCollaborate with Internal RepositoriesDistribute to the community with Public RepositoriesDistribute to customers with Private Repositories
  • 48.
    Nexus at eXofor qualityEase the Burden on Central and others remote repositoriesGain Predictability and ScalabilityControl and Audit Dependencies and ReleasesStage releases
  • 49.
  • 50.
    Tests AutomationUse automatedtests as often as you canMany tools are available through MavenJUnit, TestNG – unit tests, Selenium, Canoo – web GUI test,Fitnesse, Greenpepper – functional tests,SoapUI – web services testsJMeter – performances testsAnd many more frameworks are available to reply your needs
  • 51.
    Quality MetricsExtract qualitymetrics from your project and monitor them :Code style (CheckStyle)Bad practices or potential bugs (PMD, FindBugs, Clirr)Tests coverage (Cobertura, Emma, Clover)…You can use blocking rulesFor example, I break the build if the upward compatibility of public APIs is brokenYou can use reportsReports are available in a web site generated by MavenOr in a quality dashboard like Sonar
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
    Continuous IntegrationSetup acontinuous integration server to :Have a neutral and unmodified environment to run your testsQuickly react when The build fails (compilation failure for example)A test failsA quality metric is badContinuously improve the quality of your project and your productivityMany productsJenkins, Hudson, Bamboo, TeamCity, Continuum, Cruisecontrol, …
  • 58.
    Jenkins, how theweather is ?
  • 59.
  • 60.
  • 61.
    EclipseIntegration from maven(eclipse:eclipse)Allow many customizationsSupport many versions/variants of eclipseSupport many usages (ear …)Doesn’t support projects with “pom” packagingFew support from dev teamMany bugs in classpath managementAsynchronousYou have to regenerate and reload project each time you change a POM)
  • 62.
    EclipseIntegration from eclipse(m2eclipse)SynchronousNice UI and services to edit POMsSupport projects with “pom” packagingDoesn’t support all usages like EAR with WTPDoesn’t support very well a large number of modulesSlow down eclipse on large projects because of a lack of support of incremental build in Maven 2.x and its plugins
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
    Good & badpracticesApache Maven
  • 69.
  • 70.
    K.I.S.S.Keep It Simple,StupidStart from scratchDo not copy/paste what you find without understandingUse only what you needIt’s not because maven offers many features that you need to use themFilteringModulesProfiles…
  • 71.
    PROJECT ORGANIZATIONGOOD &BAD PracticesApache Maven
  • 72.
    Project bad practicesIgnoreMaven conventionsExcept if your are migrating from something else and the target has to be to follow them.Except if they are not compatible with your IDEDifferent versions in sub-modulesIn that case they are standalone projects.Too many inheritance levelsIt makes the POMs maintenance more complexWhere should I set this plugin parameter ? In which parent ?
  • 73.
    Project bad practicesHavetoo many modulesIs there a good reason ?Technical constraint ?Team organization ?It increases the build timeMany more artifacts to generateDependencies resolution more complexIt involves more complex developmentsMore modules to import in your IDEMore modules to update …
  • 74.
    Project good practicesUsethe default inheritance :The reactor project is also the parent of its modules.Configuration is easier :No need to redefine SCM settings, site distribution settings …
  • 75.
    POM GOOD &BAD PracticesApache Maven
  • 76.
    POM bad practicesDependencies:DON’T confuse dependencies and dependencyManagementPlugins :DON’T confuse plugins and pluginManagementDON’T use AntRunplugin everywhereDON’T let Maven choose plugins versions for you
  • 77.
    POM bad practicesProfiles:DON’T create environment dependant buildsDON’T rely on dependencies coming from profiles (there is no transitive activation of profiles)Reporting and qualityDON’T activate on an existing project all reports with default configurationDON’T control formatting rules without giving settings for IDEs.DON’T put everything you find in your POM.
  • 78.
    POM good practicesSetversions of dependencies in project parent’s dependencyManagementSet dependencies (groupId, artifactId, scope) in each module they are usedUse the dependency plugin (from apache) and versions plugin (from mojo) to analyze, cleanup and update your dependencies.
  • 79.
    Development good &bad practicesApache Maven
  • 80.
    Development bad practicesDON’Tspend your time in the terminal,DON’T exchange libraries through emails,DON’T always use "-Dmaven.test.skip=true” DON’T manually do releases
  • 81.
    Development good practicesKeepup-to-date your version of MavenFor example in 2.1 the time of dependencies/modules resolution decreased a lot (Initialization of a project of 150 modules passed from 8 minutes to less than 1)Use the reactor plugin (Maven < 2.1) or native reactor command line options (Maven >= 2.1) to rebuild only a subpart of your project :All modules depending on module XXXAll modules used to build XXX Try to not use Maven features not supported by your IDE (resources filtering with the plugineclipse:eclipse)
  • 82.
  • 83.
  • 84.
  • 85.
    arnaud@leopard:~$ mvn --encrypt-master-passwordtoto{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}
  • 86.
    We save theprivate key in ~/.m2/settings-security.xml<settingssecurity> <master>{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}</master></settingssecurity>
  • 87.
    Secure your credentialsYoucan move this key to another drive ~/.m2/settings.xml
  • 88.
  • 89.
    You create anencrypted version of your server password
  • 90.
  • 91.
    You register itin your settings
  • 92.
    <settings> ... <servers> ... <server> <id>mon.server</id> <username>arnaud</username> <password>{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}</password> </server> ... </servers> ...</settings>Build a part of Your ProjectApache Maven
  • 93.
    Using Reactor OptionsOptionsadded in maven 2.1Available in 2.0.x with the maven-reactor-pluginBut syntax is longerAllow to control what you want to build in your project
  • 94.
    Using Reactor Optionsarnaud@mbp-arnaud:~$mvn install[INFO] ------------------------------------------------[INFO] Reactor Summary:[INFO][INFO] Project ....................... SUCCESS [2.132s][INFO] ModuleA ....................... SUCCESS [5.574s][INFO] ModuleB ....................... SUCCESS [0.455s][INFO] ModuleC ....................... SUCCESS [0.396s][INFO] ModuleD ....................... SUCCESS [0.462s][INFO] ModuleE ....................... SUCCESS [0.723s][INFO] ModuleF ....................... SUCCESS [0.404s]
  • 95.
    Builds everything fromA to FUsing Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –pl moduleE,moduleB[INFO] -------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleB .................. SUCCESS [2.774s][INFO] ModuleE .................. SUCCESS [1.008s]
  • 96.
  • 97.
  • 98.
    -pl --project-list: Buildthe specified reactor projects instead of all projectsUsing Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –pl moduleD -am[INFO] ------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleA ................. SUCCESS [4.075s][INFO] ModuleB ................. SUCCESS [0.468s][INFO] ModuleC ................. SUCCESS [0.354s][INFO] ModuleD ................. SUCCESS [0.384s]
  • 99.
    Builds module D(-pl) and all modules it uses as dependencies
  • 100.
    -am --also-make: Ifa project list is specified, also make projects that the list depends on
  • 101.
    Usecase : Buildall modules required for a war, ear, …Using Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –pl moduleD -amd[INFO] ------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleD ................. SUCCESS [4.881s][INFO] ModuleE ................. SUCCESS [0.478s][INFO] ModuleF ................. SUCCESS [0.427s]
  • 102.
    Builds module D(-pl) and all modules which depend on it
  • 103.
    -amd --also-make-dependents: Ifa project list is specified, also make projects that depend on projects on the list
  • 104.
    Usecase : Checkthat a change in a module didn’t break others which are using itUsing Reactor Optionsarnaud@mbp-arnaud:~$ mvn install –rf moduleD[INFO] ------------------------------------------[INFO] Reactor Summary:[INFO][INFO] ModuleD ................. SUCCESS [9.707s][INFO] ModuleE ................. SUCCESS [0.625s][INFO] ModuleF ................. SUCCESS [0.679s] [INFO] Project ................. SUCCESS [2.467s]
  • 105.
    Restarts all thebuild from module D (-rf)
  • 106.
    -rf,--resume-from <arg>: Resume reactor from specified project
  • 107.
    Usecase : Thebuild failed a 1st time in module D, you fixed it, and restart the build were it was to end it.ReleasE Your projectApache Maven
  • 108.
    Release of awebapp in 2002Limited usage of eclipseNo WTP (Only some features in WSAD), No ability to produce WARs
  • 109.
    Release of awebapp in 2002Many manual tasksModify settings filesPackage JARsCopy libraries (external and internal) in a « lib » directoryPackage WAR (often with a zip command)Tag the code (CVS)Send the package on the integration server using FTPDeploy the package with AS console
  • 110.
    Release of awebapp in 2002One problem : The are always problemsError in config filesMissing dependenciesMissing fileLast minute fix which created a bugAnd many other possibilies ..How long did it take ?When everything is ok : 15 minutesWhen there’s a problem : ½ day or more
  • 111.
    Maven Release PluginAutomatesthe release process from tagging sources to binaries deliveryRelease plugin main goals:Prepare : To update maven versions and information in POMs and tag the codePerform : To deploy binaries in a maven repositoryAfter that you can just automate the deployment on the AS using cargo for example.
  • 112.
  • 113.
    Configuration and PrerequisitesProjectversion (must be a SNAPSHOT version)Dependencies and plugins versions mustn’t be SNAPSHOTs
  • 114.
    Troubleshooting ReleasesCommon errorsduringrelease:Buildwith release profile wastestedbefore and failsLocal modificationsCurrent version is not a SNAPSHOTSNAPSHOTs in dependencies and/or pluginsMissingsome configuration (scm, distribMgt, …)Tag alreadyexistsUnable to deployproject to the RepositoryConnectionproblems
  • 115.
    SCM configurationSCM binarieshave to be in the PATHSCM credentials have to already be stored or you have to pass them in command line with :–Dusername=XXX –Dpassword=XXX<scm> <connection>scm:svn:http://svn.acme.com/myproject/trunk</connection> <developerConnection>scm:svn:https://svn.acme.com/myproject/trunk</developerConnection> <url>http://fisheye.acme.com/browse/myproject/trunk</url></scm>
  • 116.
    Distribution ManagementWhereyouwant touploadreleasedbinariesThe url of a repositorydedicated for yourproject/corporatemavendeliveries in yourrepository manager<project> <distributionManagement> <repository> <id>repository.acme.com</id> <url>${acme.releases.repo.url}</url> </repository> . . . </distributionManagement> . . . <properties> <acme.releases.repo.url>http://repo.acme.com/acme-releases</acme.releases.repo.url> . . . </properties></project>This id willbeused in user’smaven settings (~/.m2/settings.xml)Oftenuseful to have a property to test the release process on a fakerepository, to validate a repo manager ...
  • 117.
    Repository credentialsOne serverentry isrequired per differentrepository id in distribution management of projectsIn a corporateenvironment, use a unique id for all repositorieshosted on repository managers usingsamecredentials (corporate LDAP …)<settings> ... <servers> <server> <id>repository.acme.com</id> <username>aheritier</username> <password>{ABCDEFGHIJKLMNOPQRSTUVWYZ}</password> </server> ... </servers> ...</settings>This id is the one defined in distributionManagement entry of the project to release
  • 118.
    Default Release Profilein Super POMThis profile isusedwhenyougeneratebinaries of the release with “mvnrelease:perform”By default, generates sources and javadocs jars for each module.<profile> <id>release-profile</id> <activation> <property> <name>performRelease</name> <value>true</value> </property> </activation> <build> <plugins> ... </plugins> </build></profile>This activation couldbeused in profiles youwant to activate in the release processConfiguration to generate sources and javadoc jars with basic setting
  • 119.
    Custom release profile<project>... <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.0</version> <configuration> <useReleaseProfile>false</useReleaseProfile> <releaseProfiles>myreleaseprofile</releaseProfiles> </configuration> </plugin> </plugins> </pluginManagement> </build> ... <profiles> <profile> <id>myreleaseprofile</id> <build> ... </build> </profile> </profiles> ...</project>Don’t use the default profileUse ourcustomized profileOur customized profileCustomize the behavior of the build for a releaseTake care to test isbefore the release !!
  • 120.
    SETUP a GLObalMirrorApache Maven
  • 121.
    Why should wesetup a global mirror ?To simplify users and projects settingsTo control where binaries are coming fromTo not rely on project’s repositoriesTo use only the corporate repository managerTo improve build performancesBy reducing the number of requests to find a missing artefact
  • 122.
    How should wesetup a global mirror ? <setting> <mirrors> <mirror> <id>global-mirror</id> <mirrorOf>external:*</mirrorOf> <url>http://repo.acme.com/public</url> </mirror> </mirrors> <profiles> <profile> <id>mirror</id> <repositories> <repository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>mirror</activeProfile> </activeProfiles></settings> Send all requests to this urlUse « central » id to override default maven configurationEnablesnapshotsmake the profile active all the time
  • 123.
    Back to theFutureApache Maven
  • 124.
  • 125.
    Apache Maven 2.0.xbugsfixLast release : 2.0.11No other release of 2.0.x in the future
  • 126.
    Apache Maven 2.xEvolutions,new featuresSeveral important new features in 2.1 likeParallel downloadsEncrypted passwordsReactor command line optionsLast release : 2.2.1
  • 127.
    Apache Maven 3.xDonot be afraid !!!!!Full compatibility with maven 2.x projectsOr at least at 99,99999%3.0 : October 20103.0.1 : November 20103.0.2 : January 20113.0.3 : March 2011~ every 6 weeks
  • 128.
    Apache Maven 3.x– Why ?To build new foundations for the futureThe major part of the code was reviewed / rewrittenHow POMs are constructedHow the lifecycle is executedHow the plugin manager executesHow artifacts are resolvedHow it can be embeddedHow dependency injection is done…
  • 129.
    Apache Maven 3.x- robustnessError & integrity reportingMuch improved error reporting where we will provide links to each identifiable problem we know of. There are currently 42 common things that can go wrong.Don't allow builds where versions come from non-project sources like local settings and CLI parametersDon't allow builds where versions come from profiles that have to be activated manuallyBackward compatibilitySeveral thousands of integration tests
  • 130.
    Apache Maven 3.x- performancesMany optimizationsNew support of parallel builds of modulesNew incremental (partial) buildTo improve IDE integration
  • 131.
    Apache Maven 3.x– new featuresAny-source POMIf you don’t like XML, choose another DSLVersionless parent elementsIf you don’t use versions or release plugins to automatically update themMixinsa compositional form of Maven POM configurationGlobal excludes
  • 132.
    Apache Maven 3.xWhatit will change for maven developers ?Lifecycle extension pointsPlugin extension pointsIncremental build supportQueryable lifecycleExtensible reportingBye bye Plexus, welcome JSR 330 & Google GuiceWelldefined and documented APIs
  • 133.
    Apache Maven 3.x– New tools mvnshA cross-platform shell dedicated to mavenTychoMaven ready for OSGI and Eclipse developments
  • 134.
    In Apache Maven3.0 ?A backward compatibility near to 100% for projects and pluginsA totally new implementationA greater robustness with a better reporting and more readable logsPerformances improvements and new parallel buildsA better integration for others tools like IDE or continuous integration serversNo change in current POM format
  • 135.
  • 136.
    Users Mailing Listusers@maven.apache.orgTrafficstatisticscovera total of 2025 days.Currentsubscribers: 1936Current digest subscribers: 48Total posts(2025 days): 89687Meanposts per day: 44.29http://pulse.apache.org/Blue : Number of subscribersRed : Number of messages per day
  • 137.
  • 138.
  • 139.
    The team60 committers,Morethan 30 active in 2009,Several organizations like Sonatype, deliver resources and professional support,A community less isolated : more interactions with Eclipse, Jetty,
  • 140.
  • 141.
  • 142.
    Choose your wayof thinkingConventions approachScripting approach
  • 143.
    CompetitorsAnt + Ivy,Easy Ant, Gant, Gradle, Buildr…Script orientedYou can do what you want !Reuse many of Maven conventions (directories layout, …) and services (repositories) but without enforcing themThe risk for them : Not being able to evolve due to the too high level of customization proposed to the user. We tried on Maven 1 and it died because of that. It was impossible to create a set of tests to cover all usages.It’s like providing a framework without public API 
  • 144.
    With scripts orientedbuildsYou can have(if you have good skills)But often you have(moreover after years …)
  • 145.
    With MavenWe dreamto deliver(Maven 3.x)But today we have too often(Maven 2.x)
  • 146.
  • 147.
    ConclusionToday, Maven iswidely adopted in corporate environments,It provides many services,It has an important and really active community of users and developersMany resources to learn to use it and a professional support are availableA product probably far from being perfect but on rails for the future. Maven 3.0 is a new start.Many things to doWe need you !
  • 148.
  • 149.
    Licence et copyrightsPhotosand logos belong to their respective authors/ownersContent underCreative Commons 3.0Attribution — You must attribute the work in the mannerspecified by the author or licensor (but not in anywaythatsuggeststhattheyendorseyou or your use of the work).Noncommercial — You may not use thiswork for commercial purposes.ShareAlike — If you alter, transform, or builduponthiswork, youmaydistribute the resultingworkonlyunder the same or similarlicense to this one.http://creativecommons.org/licenses/by-nc-sa/3.0/us/
  • 150.
    To go Further…Apache Maven
  • 151.
  • 152.
    Some links The mainweb site :http://maven.apache.orgProject’s team wiki :http://docs.codehaus.org/display/MAVENProject’suserswiki :http://docs.codehaus.org/display/MAVENUSER
  • 153.
    BooksNicolas De loofArnaudHéritierPublished by PearsonCollection RéférenceBased on our own experiences with Maven. From beginners to experts.In French only
  • 154.
    BooksSonatype / O’Reilly:The Definitive Guidehttp://www.sonatype.com/booksFree downloadAvailable in several languages
  • 155.
    BooksApache Maven 2Effective ImplementationBrett Porter, Maria OdeaChinghttps://www.packtpub.com/apache-maven-2-effective-implementation/book
  • 156.
    BooksExist GlobalBetter buildswith Mavenhttp://www.maestrodev.com/better-build-mavenFree download
  • 157.
  • 158.
    SupportMailing listshttp://maven.apache.org/mail-lists.htmlIRCirc.codehaus.org -#mavenForumshttp://www.developpez.net/ forum mavenIn FrenchDedicated supportSonatypeand many others companies