Apache MavenMarsJUG<br />Arnaud Héritier<br />eXo platform<br />Software Factory Manager<br />
Arnaud Héritier<br />Committer since 2004 and member of the Project Management Committee<br />Coauthor of « Apache Maven »...
Overview<br />Apache Maven<br />
Basics<br />Apache Maven<br />4<br />
Definition<br />Apache Maven is a software project management and comprehension tool. <br />Based on the concept of a proj...
Conventions<br />1 project = 1 artifact (pom, jar, war, ear, …)<br />Standardized<br />directories layout<br />projectdesc...
POM<br />An XML file (pom.xml)<br />Describing<br />Project identification<br />Project version<br />Project description<b...
WithoutMaven<br />WithMaven<br />Dependencies<br />
Dependencies<br />Declaratives<br />groupId+artifactId+version (+ classifier)<br />Type (packaging): jar, war, pom, ear, …...
Dependencies<br />Scope<br />Compile (by default) : Required to build and run the application<br />Runtime : not required ...
ArtifactRepository<br />By default :<br />A central repository<br />http://repo1.maven.org/maven2<br />Severaldozen of Gb ...
Artifact Repository<br />By default Maven downloads artifacts required by the project or itself from central<br />Download...
Versions<br />Project and dependency versions<br />Two different version variants<br />SNAPSHOT version<br />The version n...
Versions<br />
Versions<br />About SNAPSHOT dependencies<br />Maven allows the configuration of an update policy. The update policy defin...
Versions<br />Range<br />From … to … <br />Maven automatically searches for the corresponding version (using the update po...
Reactor<br />pom.xml :<br />&lt;modules&gt;<br /> &lt;module&gt;moduleA&lt;/module&gt;<br /> &lt;module&gt;moduleC&lt;/mod...
Inheritence<br />Share settings between projects/modules<br />Project<br />Business1<br />Jar<br />War<br />Business2<br /...
BuildLifecycle And Plugins<br />Plugin based architecture for a great extensibility<br />Standardized lifecycle to build a...
Whydoes a projectchooseMaven?<br />Apache Maven<br />
Maven, the project’s choice<br />Application’s architecture<br />The project has the freedom to divide the application in ...
Maven, the project’s choice<br />Centralizes and automates all development facets (build, tests, releases)<br />One thing ...
Whydoes a companychooseMaven?<br />Apache Maven<br />
Maven, the corporate’s choice<br />Widely adopted and known<br />Many developers<br />Developments are standardized<br />D...
ecosystem<br />Apache Maven<br />
Maven’s ecosytem<br />Mavenaloneisnothing<br />You can integrate it with many tools<br />
repository managerS<br />Apache Maven<br />
Repository Managers<br />Basic services<br />Search artifacts<br />Browse repositories<br />Proxy external repositories<br...
Secure your builds<br />Deploy a repository manager to proxy externals repositories to :<br />Avoid external network outag...
Setup a global mirror<br />&lt;settings&gt;<br /> &lt;mirrors&gt;<br />  &lt;mirror&gt;<br />   &lt;!--Thissendseverything...
Quality management<br />Apache Maven<br />
Automate tests<br />Use automated tests as often as you can<br />Many tools are available through Maven<br />JUnit, TestNG...
Quality Metrics<br />Extract quality metrics from your project and monitor them :<br />Code style (CheckStyle)<br />Bad pr...
Dependency Report<br />
Sonar Dashboard<br />
Continuous integration<br />Apache Maven<br />
Continuous Integration<br />Setup a continuous integration server to :<br />Have a neutral and unmodified environment to r...
Hudson<br />
Good & bad practices<br />Apache Maven<br />
KISS<br />Apache Maven<br />
K.I.S.S.<br />Keep It Simple, Stupid<br />Start from scratch<br />Do not copy/paste what you find without understanding<br...
PROJECT ORGANIZATIONGOOD & BAD Practices<br />Apache Maven<br />
Project bad practices<br />Ignore Maven conventions<br />Except if your are migrating from something else and the target h...
Project bad practices<br />Have too many modules<br />Is there a good reason ?<br />Technical constraint ?<br />Team organ...
Project good practices<br />Use the default inheritance :<br />The reactor project is also the parent of its modules.<br /...
POM GOOD & BAD Practices<br />Apache Maven<br />
POM bad practices<br />Dependencies :<br />DON’T confuse dependencies and dependencyManagement<br />Plugins :<br />DON’T c...
POM bad practices<br />Profiles :<br />DON’T create environment dependant builds<br />DON’T rely on dependencies coming fr...
POM good practices<br />Set versions of dependencies in project parent’s dependencyManagement<br />Set dependencies (group...
Development good & bad practices<br />Apache Maven<br />
Development bad practices<br />DON’T spend your time in the terminal,<br />DON’T exchange libraries through emails,<br />D...
Development good practices<br />Keep up-to-date your version of Maven<br />For example in 2.1 the time of dependencies/mod...
Usecases<br />Apache Maven<br />
Secure your credentials<br />Apache Maven<br />
Secure your credentials<br />Generate a private keyarnaud@leopard:~$ mvn--encrypt-master-passwordtoto{dZPuZ74YTJ0HnWHGm4zg...
Secure your credentials<br />You can move this key to another drive~/.m2/settings.xml&lt;settingssecurity&gt;&lt;relocatio...
Build a part of Your Project<br />Apache Maven<br />
Reactor options (Maven &gt; 2.1)<br />
ReleasE Your project<br />Apache Maven<br />
Release of awebappin 2002<br />Limited usage of eclipse<br />NoWTP (Onlysomefeaturesin WSAD),<br />Noabilitytoproduce WARs...
Release of a webapp in 2002<br />Many manual tasks<br />Modify settings files<br />Package JARs<br />Copy libraries (exter...
Release of a webapp in 2002<br />One problem : The are always problems<br />Error in config files<br />Missing dependencie...
Maven Release Plugin<br />Automates the release process from tagging sources to binaries delivery<br />Release plugin main...
Maven Release Plugin<br />
Configuration and Prerequisites<br />Project version (must be a SNAPSHOT version)<br />Dependencies and plugins versions m...
SCM configuration<br />SCM binaries have to be in the PATH<br />SCM credentials have to already be stored or you have to p...
Distribution Management<br />&lt;project&gt;<br /> &lt;distributionManagement&gt;<br />  &lt;repository&gt;<br />   &lt;id...
Repository credentials<br />&lt;settings&gt;<br /> &lt;servers&gt;<br />  &lt;server&gt;<br />   &lt;!–- id must be the on...
Default Release Profile in Super POM<br />&lt;profile&gt;<br /> &lt;id&gt;release-profile&lt;/id&gt;<br /> &lt;activation&...
Custom release profile<br />&lt;project&gt;<br /> ...<br /> &lt;build&gt;<br />  &lt;pluginManagement&gt;<br />   &lt;plug...
Troubleshooting Releases<br />Common errorsduring release:<br />Buildwith release profile wastestedbefore and fails<br />L...
To go Further …<br />Apache Maven<br />
DOCUMENTATIONS<br />Apache Maven<br />
Some links	<br />The main web site :<br />http://maven.apache.org<br />Project’s team wiki :<br />http://docs.codehaus.org...
Books<br />Sonatype / O’Reilly :<br />The Definitive Guide<br />http://www.sonatype.com/books<br />Free download<br />Avai...
Books<br />Exist Global<br />Better builds with Maven<br />http://www.maestrodev.com/better-build-maven<br />Free download...
Books<br />Nicolas De loofArnaud Héritier<br />Published by Pearson<br />Collection Référence<br />Based on our own experi...
Support<br />Apache Maven<br />
Support<br />Mailing lists<br />http://maven.apache.org/mail-lists.html<br />IRC<br />irc.codehaus.org - #maven<br />Forum...
Back to the Future<br />Apache Maven<br />
product<br />Apache Maven<br />
Apache Maven 2.0.x<br />bugs fix<br />Last release : 2.0.10<br />No 2.0.11 planned<br />
Apache Maven 2.x<br />Evolutions, new features<br />Several important new features in 2.1 like<br />Parallel downloads<br ...
Apache Maven 3.x<br />Do not be afraid !!!!!<br />Not final before at least one year<br />Full compatibility with maven 2....
Apache Maven 3.x<br />What’s new :<br />How POMs are constructed<br />How the lifecycle is executed<br />How the plugin ma...
Apache Maven 3.x<br />What it will change for maven users ?<br />Any-source POM<br />Versionless parent elements<br />Mixi...
Apache Maven 3.x<br />What it will changefor maven developers ?<br />Lifecycle extension points<br />Plugin extension poin...
Community<br />Apache Maven<br />
Users community<br />90 days statistics<br />Number of subscribers in blue<br />Number of messages per day in red<br />178...
The web site<br />
Dowloads<br />Permonth downloads<br />
The team<br />60 committers,<br />More than 30 active since the beginning of the year,<br />Several organizations like Son...
Commit Statistics<br />
Competitors<br />Apache Maven<br />
Competitors<br />Ant + Ivy, Easy Ant, Gant, Graddle, Buildr…<br />Script oriented<br />You can do what you want !<br />Reu...
Conclusion<br />Apache Maven<br />
Conclusion<br />Today, Maven is widely adopted in corporate environments,<br />It provides many services,<br />It has an i...
Questions ?<br />Apache Maven<br />
Licence et copyrights<br />Photos and logos belong to their respective authors/owners<br />Content underCreative Commons 3...
Upcoming SlideShare
Loading in...5
×

20091112 - Mars Jug - Apache Maven

2,893

Published on

MarsJUG - 12 Nov 2009 - Apache Maven

Published in: Technology
3 Comments
8 Likes
Statistics
Notes
No Downloads
Views
Total Views
2,893
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
189
Comments
3
Likes
8
Embeds 0
No embeds

No notes for slide

Transcript of "20091112 - Mars Jug - Apache Maven"

  1. 1. Apache MavenMarsJUG<br />Arnaud Héritier<br />eXo platform<br />Software Factory Manager<br />
  2. 2. Arnaud Héritier<br />Committer since 2004 and member of the Project Management Committee<br />Coauthor of « Apache Maven » published by Pearson (in French)<br />Software Factory Manager at eXo platform <br />In charge of tools and methods<br />
  3. 3. Overview<br />Apache Maven<br />
  4. 4. Basics<br />Apache Maven<br />4<br />
  5. 5. Definition<br />Apache Maven is a software project management and comprehension tool. <br />Based on the concept of a project object model (POM), Maven can manage a project&apos;s build, binaries, reporting and documentation from a central piece of information.<br />Apache Maven is a command line tool with some IDE integrations.<br />
  6. 6. Conventions<br />1 project = 1 artifact (pom, jar, war, ear, …)<br />Standardized<br />directories layout<br />projectdescriptor (POM)<br />buildlifecycle<br />6<br />
  7. 7. POM<br />An XML file (pom.xml)<br />Describing<br />Project identification<br />Project version<br />Project description<br />Build settings<br />Dependencies<br />…<br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />&lt;project&gt;<br /> &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br /> &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;<br /> &lt;artifactId&gt;webapp-sample&lt;/artifactId&gt;<br /> &lt;version&gt;1.1-SNAPSHOT&lt;/version&gt;<br /> &lt;packaging&gt;war&lt;/packaging&gt;<br /> &lt;name&gt;Simple webapp&lt;/name&gt;<br /> &lt;inceptionYear&gt;2007&lt;/inceptionYear&gt;<br /> &lt;dependencies&gt;<br /> &lt;dependency&gt;<br /> &lt;groupId&gt;org.springframework&lt;/groupId&gt;<br /> &lt;artifactId&gt;spring-struts&lt;/artifactId&gt;<br /> &lt;version&gt;2.0.2&lt;/version&gt;<br /> &lt;/dependency&gt;<br /> ...<br /> &lt;/dependencies&gt;<br />&lt;/project&gt;<br />
  8. 8. WithoutMaven<br />WithMaven<br />Dependencies<br />
  9. 9. Dependencies<br />Declaratives<br />groupId+artifactId+version (+ classifier)<br />Type (packaging): jar, war, pom, ear, …<br />Transitives<br />LibAneedsLib B<br />LibBneedsLib C<br />ThusLibAneedsLib C<br />
  10. 10. Dependencies<br />Scope<br />Compile (by default) : Required to build and run the application<br />Runtime : not required to build theapplication but needed at runtime<br />Ex : taglibs<br />Provided : required to build theapplication but not needed at runtime (provided by the container)<br />Ex : Servlet API, Driver SGBD, …<br />Test : required to build and launch tests but not needed by theapplication itself to build and run<br />Ex : Junit, TestNG, DbUnit, …<br />System : local library with absolute path<br />Ex : software products<br />
  11. 11. ArtifactRepository<br />By default :<br />A central repository<br />http://repo1.maven.org/maven2<br />Severaldozen of Gb of OSS libraries<br />A local repository<br />${user.home}/.m2/repository<br />All artifacts<br />Used by maven and its plugins<br />Used by yourprojects (dependencies)<br />Produced by yourprojects<br />
  12. 12. Artifact Repository<br />By default Maven downloads artifacts required by the project or itself from central<br />Downloaded artifacts are stored in the local repository<br />
  13. 13. Versions<br />Project and dependency versions<br />Two different version variants<br />SNAPSHOT version<br />The version number ends with –SNAPSHOT<br />The project is in development <br />Deliveries are changing over the time and are overridden after each build<br />Artifacts are deployed with a timestamp on remote repositories<br />RELEASE version<br />The version number doesn’t end with –SNAPSHOT<br />Binaries won’t change<br />
  14. 14. Versions<br />
  15. 15. Versions<br />About SNAPSHOT dependencies<br />Maven allows the configuration of an update policy. The update policy defines the recurrence of checks if there is a new SNAPSHOT version available on the remote repository :<br />always<br />daily (by default)<br />interval:X (a given period in minutes)<br />never<br />Must not be used in a released project<br />They can change thus the release also <br />
  16. 16. Versions<br />Range<br />From … to … <br />Maven automatically searches for the corresponding version (using the update policy for released artifacts)<br />To use with caution<br />Risk of non reproducibility of the build<br />Risk of sideeffectson projects depending on yours.<br />
  17. 17. Reactor<br />pom.xml :<br />&lt;modules&gt;<br /> &lt;module&gt;moduleA&lt;/module&gt;<br /> &lt;module&gt;moduleC&lt;/module&gt;<br /> &lt;module&gt;moduleB&lt;/module&gt;<br />&lt;/modules&gt;<br />Ability of Maven to build several sub-modules resolving the order of their dependencies<br />Modules have to be defined in the POM<br />For a performance reasons<br />
  18. 18. Inheritence<br />Share settings between projects/modules<br />Project<br />Business1<br />Jar<br />War<br />Business2<br />Jar<br />War<br />By default the parent project is supposed to be in the parent directory (../)<br />pom.xml for module Jar1<br />&lt;parent&gt;<br /> &lt;groupId&gt;X.Y.Z&lt;/groupId&gt;<br /> &lt;artifactId&gt;jars&lt;/artifactId&gt;<br /> &lt;version&gt;1.0-SNAPSHOT&lt;version&gt;<br />&lt;/parent&gt;<br />
  19. 19. BuildLifecycle And Plugins<br />Plugin based architecture for a great extensibility<br />Standardized lifecycle to build all types of archetypes<br />
  20. 20. Whydoes a projectchooseMaven?<br />Apache Maven<br />
  21. 21. Maven, the project’s choice<br />Application’s architecture<br />The project has the freedom to divide the application in modules<br />Maven doesn’t limit the evolution of the application architecture<br />Dependencies management<br />Declarative : Maven automatically downloads them and builds the classpath<br />Transitive : We define only what the module needs itself<br />
  22. 22. Maven, the project’s choice<br />Centralizes and automates all development facets (build, tests, releases)<br />One thing it cannot do for you : to develop <br />Builds<br />Tests<br />Packages<br />Deploys<br />Documents<br />Checks and reports about the quality of developments<br />
  23. 23. Whydoes a companychooseMaven?<br />Apache Maven<br />
  24. 24. Maven, the corporate’s choice<br />Widely adopted and known<br />Many developers<br />Developments are standardized<br />Decrease of costs<br />Reuse of knowledge<br />Reuse of configuration fragments<br />Reuse of process and code fragments<br />Product qualityimprovement<br />Reports and monitoring<br />
  25. 25. ecosystem<br />Apache Maven<br />
  26. 26. Maven’s ecosytem<br />Mavenaloneisnothing<br />You can integrate it with many tools<br />
  27. 27. repository managerS<br />Apache Maven<br />
  28. 28. Repository Managers<br />Basic services<br />Search artifacts<br />Browse repositories<br />Proxy external repositories<br />Host internal repositories<br />Security<br />Several products<br />Sonatype Nexus (replaced Proximity)<br />JfrogArtifactory<br />Apache Archiva<br />
  29. 29. Secure your builds<br />Deploy a repository manager to proxy externals repositories to :<br />Avoid external network outages<br />Avoid external repository unavailabilities<br />To reduce your company’s external network usage<br />To increase the speed of artifact downloads<br />Additional services offered by such servers :<br />Artifacts procurement to filter what is coming from the outside<br />Staging repository to validate your release before deploying it<br />
  30. 30. Setup a global mirror<br />&lt;settings&gt;<br /> &lt;mirrors&gt;<br /> &lt;mirror&gt;<br /> &lt;!--Thissendseverythingelse to /public --&gt;<br /> &lt;id&gt;global-mirror&lt;/id&gt;<br /> &lt;mirrorOf&gt;external:*&lt;/mirrorOf&gt;<br /> &lt;url&gt;http://repository.exoplatform.org/content/groups/all&lt;/url&gt;<br /> &lt;/mirror&gt;<br /> &lt;/mirrors&gt;<br /> &lt;profiles&gt;<br /> &lt;profile&gt;<br /> &lt;id&gt;mirror&lt;/id&gt;<br /> &lt;!--Enablesnapshots for the built in central repo to direct --&gt;<br /> &lt;!--allrequests to the repository manager via the mirror --&gt;<br /> &lt;repositories&gt;<br /> &lt;repository&gt;<br /> &lt;id&gt;central&lt;/id&gt;<br /> &lt;url&gt;http://central&lt;/url&gt;<br /> &lt;releases&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/releases&gt;<br /> &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;<br /> &lt;/repository&gt;<br /> &lt;/repositories&gt;<br /> &lt;pluginRepositories&gt;<br /> &lt;pluginRepository&gt;<br /> &lt;id&gt;central&lt;/id&gt;<br /> &lt;url&gt;http://central&lt;/url&gt;<br /> &lt;releases&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/releases&gt;<br /> &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;<br /> &lt;/pluginRepository&gt;<br /> &lt;/pluginRepositories&gt;<br /> &lt;/profile&gt;<br /> &lt;/profiles&gt;<br /> &lt;activeProfiles&gt;<br /> &lt;!--make the profile active all the time --&gt;<br /> &lt;activeProfile&gt;mirror&lt;/activeProfile&gt;<br /> &lt;/activeProfiles&gt;<br />&lt;/settings&gt;<br />
  31. 31. Quality management<br />Apache Maven<br />
  32. 32. Automate tests<br />Use automated tests as often as you can<br />Many tools are available through Maven<br />JUnit, TestNG – unit tests, <br />Selenium, Canoo – web GUI test,<br />Fitnesse, Greenpepper – functional tests,<br />SoapUI – web services tests<br />JMeter– performances tests<br />And many more frameworks are available to reply your needs<br />
  33. 33. Quality Metrics<br />Extract quality metrics from your project and monitor them :<br />Code style (CheckStyle)<br />Bad practices or potential bugs (PMD, FindBugs, Clirr)<br />Tests coverage (Cobertura, Emma, Clover)<br />…<br />You can use blocking rules<br />For example, I break the build if the upward compatibility of public APIs is broken<br />You can use reports<br />Reports are available in a web site generated by Maven<br />Or in a quality dashboard like Sonar<br />
  34. 34. Dependency Report<br />
  35. 35. Sonar Dashboard<br />
  36. 36. Continuous integration<br />Apache Maven<br />
  37. 37. Continuous Integration<br />Setup a continuous integration server to :<br />Have a neutral and unmodified environment to run your tests<br />Quickly react when <br />The build fails (compilation failure for example)<br />A test fails<br />A quality metric is bad<br />Continuously improve the quality of your project and your productivity<br />Many products<br />Hudson, Bamboo, TeamCity, Continuum, Cruisecontrol, …<br />
  38. 38. Hudson<br />
  39. 39. Good & bad practices<br />Apache Maven<br />
  40. 40. KISS<br />Apache Maven<br />
  41. 41. K.I.S.S.<br />Keep It Simple, Stupid<br />Start from scratch<br />Do not copy/paste what you find without understanding<br />Use only what you need<br />It’s not because maven offers many features that you need to use them<br />Filtering<br />Modules<br />Profiles<br />…<br />
  42. 42. PROJECT ORGANIZATIONGOOD & BAD Practices<br />Apache Maven<br />
  43. 43. Project bad practices<br />Ignore Maven conventions<br />Except if your are migrating from something else and the target has to be to follow them.<br />Except if they are not compatible with your IDE<br />Different versions in sub-modules<br />In that case they are standalone projects.<br />Too many inheritance levels<br />It makes the POMsmaintenance more complex<br />Where should I set this plugin parameter ? In which parent ?<br />
  44. 44. Project bad practices<br />Have too many modules<br />Is there a good reason ?<br />Technical constraint ?<br />Team organization ?<br />It increases the build time<br />Many more artifacts to generate<br />Dependencies resolution more complex<br />It involves more complex developments<br />More modules to import in your IDE<br />More modules to update …<br />
  45. 45. Project good practices<br />Use the default inheritance :<br />The reactor project is also the parent of its modules.<br />Configuration is easier :<br />No need to redefine SCM settings, site distribution settings …<br />
  46. 46. POM GOOD & BAD Practices<br />Apache Maven<br />
  47. 47. POM bad practices<br />Dependencies :<br />DON’T confuse dependencies and dependencyManagement<br />Plugins :<br />DON’T confuse plugins and pluginManagement<br />DON’T use AntRunplugin everywhere<br />DON’T let Maven choose plugins versions for you<br />
  48. 48. POM bad practices<br />Profiles :<br />DON’T create environment dependant builds<br />DON’T rely on dependencies coming from profiles (there is no transitive activation of profiles)<br />Reporting and quality<br />DON’T activate on an existing project all reports with default configuration<br />DON’T control formatting rules without giving settings for IDEs.<br />DON’T put everything you find in your POM.<br />
  49. 49. POM good practices<br />Set versions of dependencies in project parent’s dependencyManagement<br />Set dependencies (groupId, artifactId, scope) in each module they are used<br />Use the dependency plugin (from apache) and versions plugin (from mojo) to analyze, cleanup and update your dependencies.<br />
  50. 50. Development good & bad practices<br />Apache Maven<br />
  51. 51. Development bad practices<br />DON’T spend your time in the terminal,<br />DON’T exchange libraries through emails,<br />DON’T always use &quot;-Dmaven.test.skip=true” <br />DON’T manually do releases<br />
  52. 52. Development good practices<br />Keep up-to-date your version of Maven<br />For example in 2.1 the time of dependencies/modules resolution decreased a lot (Initialization of a project of 150 modules passed from 8 minutes to less than 1)<br />Use the reactor plugin (Maven &lt; 2.1) or native reactor command line options (Maven &gt;= 2.1) to rebuild only a subpart of your project :<br />All modules depending on module XXX<br />All modules used to build XXX <br />Try to not use Maven features not supported by your IDE (resources filtering with the plugineclipse:eclipse)<br />
  53. 53. Usecases<br />Apache Maven<br />
  54. 54. Secure your credentials<br />Apache Maven<br />
  55. 55. Secure your credentials<br />Generate a private keyarnaud@leopard:~$ mvn--encrypt-master-passwordtoto{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}<br />We save the private key in ~/.m2/settings-security.xml&lt;settingssecurity&gt;&lt;master&gt;{dZPuZ74YTJ0HnWHGm4zgfDlruYQNda1xib9vAVf2vvY=}&lt;/master&gt;&lt;/settingssecurity&gt;<br />
  56. 56. Secure your credentials<br />You can move this key to another drive~/.m2/settings.xml&lt;settingssecurity&gt;&lt;relocation&gt;/Volumes/ArnaudUsbKey/secure/settings-security.xml&lt;/relocation&gt;&lt;/settingssecurity&gt;<br />You create an encrypted version of your server passwordarnaud@leopard:~$ mvn--encrypt-password titi{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}<br />You register it in your settings&lt;settings&gt; ... &lt;servers&gt; ... &lt;server&gt; &lt;id&gt;mon.server&lt;/id&gt; &lt;username&gt;arnaud&lt;/username&gt; &lt;password&gt;{SbC9Fl2jA4oHZtz5Fcefp2q1tMXEtBkz9QiKljPiHss=}&lt;/password&gt; &lt;/server&gt; ... &lt;/servers&gt; ...&lt;/settings&gt;<br />
  57. 57. Build a part of Your Project<br />Apache Maven<br />
  58. 58. Reactor options (Maven &gt; 2.1)<br />
  59. 59. ReleasE Your project<br />Apache Maven<br />
  60. 60. Release of awebappin 2002<br />Limited usage of eclipse<br />NoWTP (Onlysomefeaturesin WSAD),<br />Noabilitytoproduce WARs<br />
  61. 61. Release of a webapp in 2002<br />Many manual tasks<br />Modify settings files<br />Package JARs<br />Copy libraries (external and internal) in a « lib » directory<br />Package WAR (often with a zip command)<br />Tag the code (CVS)<br />Send the package on the integration server using FTP<br />Deploy the package with AS console <br />
  62. 62. Release of a webapp in 2002<br />One problem : The are always problems<br />Error in config files<br />Missing dependencies<br />Missing file<br />Last minute fix which created a bug<br />And many other possibilies ..<br />How long did it take ?<br />When everything is ok : 15 minutes<br />When there’s a problem : ½ day or more<br />
  63. 63. Maven Release Plugin<br />Automates the release process from tagging sources to binaries delivery<br />Release plugin main goals:<br />Prepare : To update maven versions and information in POMs and tag the code<br />Perform : To deploy binaries in a maven repository<br />After that you can just automate the deployment on the AS using cargo for example.<br />
  64. 64. Maven Release Plugin<br />
  65. 65. Configuration and Prerequisites<br />Project version (must be a SNAPSHOT version)<br />Dependencies and plugins versions mustn’t be SNAPSHOTs<br />
  66. 66. SCM configuration<br />SCM binaries have to be in the PATH<br />SCM credentials have to already be stored or you have to pass them in command line with :–Dusername=XXX –Dpassword=XXX<br />&lt;scm&gt;<br /> &lt;connection&gt;<br />scm:svn:http://svn.exoplatform.org/projects/parent/trunk<br /> &lt;/connection&gt;<br /> &lt;developerConnection&gt;<br />scm:svn:http://svn.exoplatform.org/projects/parent/trunk<br /> &lt;/developerConnection&gt;<br /> &lt;url&gt;<br /> http://fisheye.exoplatform.org/browse/projects/parent/trunk<br /> &lt;/url&gt;<br />&lt;/scm&gt;<br />
  67. 67. Distribution Management<br />&lt;project&gt;<br /> &lt;distributionManagement&gt;<br /> &lt;repository&gt;<br /> &lt;id&gt;repository.exoplatform.org&lt;/id&gt;<br /> &lt;url&gt;${exo.releases.repo.url}&lt;/url&gt;<br /> &lt;/repository&gt;<br /> . . .<br /> &lt;/distributionManagement&gt;<br /> . . . <br /> &lt;properties&gt;<br />&lt;exo.releases.repo.url&gt;<br />http://repository.exoplatform.org/content/repositories/exo-releases<br /> &lt;/exo.releases.repo.url&gt;<br /> . . .<br /> &lt;/properties&gt;<br />&lt;/project&gt;<br />
  68. 68. Repository credentials<br />&lt;settings&gt;<br /> &lt;servers&gt;<br /> &lt;server&gt;<br /> &lt;!–- id must be the one used in distributionManagement --&gt;<br /> &lt;id&gt;repository.exoplatform.org&lt;/id&gt;<br /> &lt;username&gt;aheritier&lt;/username&gt;<br /> &lt;password&gt;{ABCDEFGHIJKLMNOPQRSTUVWYZ}&lt;/password&gt;<br /> &lt;/server&gt;<br /> &lt;/servers&gt;<br />&lt;/settings&gt;<br />
  69. 69. Default Release Profile in Super POM<br />&lt;profile&gt;<br /> &lt;id&gt;release-profile&lt;/id&gt;<br /> &lt;activation&gt;<br /> &lt;property&gt;<br /> &lt;name&gt;performRelease&lt;/name&gt;<br /> &lt;value&gt;true&lt;/value&gt;<br /> &lt;/property&gt;<br /> &lt;/activation&gt;<br /> &lt;build&gt;<br /> &lt;plugins&gt;<br /> &lt;!–- Configuration to generate sources and javadoc jars --&gt;<br /> ...<br /> &lt;/plugins&gt;<br /> &lt;/build&gt;<br />&lt;/profile&gt;<br />
  70. 70. Custom release profile<br />&lt;project&gt;<br /> ...<br /> &lt;build&gt;<br /> &lt;pluginManagement&gt;<br /> &lt;plugins&gt;<br /> &lt;plugin&gt;<br /> &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br /> &lt;artifactId&gt;maven-release-plugin&lt;/artifactId&gt;<br /> &lt;version&gt;2.0-beta-9&lt;/version&gt;<br /> &lt;configuration&gt;<br /> &lt;useReleaseProfile&gt;false&lt;/useReleaseProfile&gt;<br /> &lt;arguments&gt;-Pmyreleaseprofile&lt;/arguments&gt;<br /> &lt;/configuration&gt;<br /> &lt;/plugin&gt;<br /> &lt;/plugins&gt;<br /> &lt;/pluginManagement&gt;<br /> &lt;/build&gt;<br />...<br /> &lt;profiles&gt;<br /> &lt;profile&gt;<br /> &lt;id&gt;myreleaseprofile&lt;/id&gt;<br /> &lt;build&gt;<br /> &lt;!-– what you want to customize the behavior of the build when you do a release --&gt;<br /> &lt;/build&gt;<br /> &lt;/profile&gt;<br /> &lt;/profiles&gt;<br /> ...<br />&lt;/project&gt;<br />
  71. 71. Troubleshooting Releases<br />Common errorsduring release:<br />Buildwith release profile wastestedbefore and fails<br />Local modifications<br />Current version is not a SNAPSHOT<br />SNAPSHOTs in dependencies and/or plugins<br />Missingsome configuration (scm, distribMgt, …)<br />Tag alreadyexists<br />Unable to deployproject to the Repository<br />Connectionproblems<br />
  72. 72. To go Further …<br />Apache Maven<br />
  73. 73. DOCUMENTATIONS<br />Apache Maven<br />
  74. 74. Some links <br />The main web site :<br />http://maven.apache.org<br />Project’s team wiki :<br />http://docs.codehaus.org/display/MAVEN<br />Project’suserswiki :<br />http://docs.codehaus.org/display/MAVENUSER<br />
  75. 75. Books<br />Sonatype / O’Reilly :<br />The Definitive Guide<br />http://www.sonatype.com/books<br />Free download<br />Available in several languages<br />Soon in French<br />
  76. 76. Books<br />Exist Global<br />Better builds with Maven<br />http://www.maestrodev.com/better-build-maven<br />Free download<br />
  77. 77. Books<br />Nicolas De loofArnaud Héritier<br />Published by Pearson<br />Collection Référence<br />Based on our own experiences with Maven. From beginners to experts.<br />In French only<br />Available on 20th November<br />
  78. 78. Support<br />Apache Maven<br />
  79. 79. Support<br />Mailing lists<br />http://maven.apache.org/mail-lists.html<br />IRC<br />irc.codehaus.org - #maven<br />Forums<br />http://www.developpez.net/ forum maven<br />In French<br />Dedicated support<br />Sonatype and some others companies<br />
  80. 80. Back to the Future<br />Apache Maven<br />
  81. 81. product<br />Apache Maven<br />
  82. 82. Apache Maven 2.0.x<br />bugs fix<br />Last release : 2.0.10<br />No 2.0.11 planned<br />
  83. 83. Apache Maven 2.x<br />Evolutions, new features<br />Several important new features in 2.1 like<br />Parallel downloads<br />Encrypted passwords<br />Last release : 2.2.1<br />2.2.2 in few months, 2.3 in 2010<br />
  84. 84. Apache Maven 3.x<br />Do not be afraid !!!!!<br />Not final before at least one year<br />Full compatibility with maven 2.x projects<br />
  85. 85. Apache Maven 3.x<br />What’s new :<br />How POMs are constructed<br />How the lifecycle is executed<br />How the plugin manager executes<br />How artifacts are resolved<br />How it can be embedded<br />How dependency injection is done<br />
  86. 86. Apache Maven 3.x<br />What it will change for maven users ?<br />Any-source POM<br />Versionless parent elements<br />Mixins : a compositional form of Maven POM configuration<br />Better IDE integration<br />Error & integrityreporting<br />Much improvederrorreportingwherewewillprovide links to each identifiable problemwe know of. There are currently 42 commonthingsthatcan go wrong.<br />Don&apos;tallowbuildswhere versions come fromnon-project sources like local settings and CLI parameters<br />Don&apos;tallowbuildswhere versions come from profiles that have to beactivatedmanually<br />
  87. 87. Apache Maven 3.x<br />What it will changefor maven developers ?<br />Lifecycle extension points<br />Plugin extension points<br />Incremental build support<br />Queryable lifecycle<br />Extensible reporting<br />
  88. 88. Community<br />Apache Maven<br />
  89. 89. Users community<br />90 days statistics<br />Number of subscribers in blue<br />Number of messages per day in red<br />1780 subscribers on users mailing list<br />
  90. 90. The web site<br />
  91. 91. Dowloads<br />Permonth downloads<br />
  92. 92. The team<br />60 committers,<br />More than 30 active since the beginning of the year,<br />Several organizations like Sonatype, deliver resources and professional support,<br />A community less isolated : more interactions with Eclipse, Jetty, <br />
  93. 93. Commit Statistics<br />
  94. 94. Competitors<br />Apache Maven<br />
  95. 95. Competitors<br />Ant + Ivy, Easy Ant, Gant, Graddle, Buildr…<br />Script oriented<br />You can do what you want !<br />Reuse many of Maven conventions (directories layout, …) and services (repositories) but without enforcing them<br />The risk for them :<br />Not being able to evolve due to the too high level of customization proposed to the user.<br />We tried on Maven 1 and it died because of that.<br />It’s like providing a framework without public API.<br />
  96. 96. Conclusion<br />Apache Maven<br />
  97. 97. Conclusion<br />Today, Maven is widely adopted in corporate environments,<br />It provides many services,<br />It has an important and really active community of users and developers<br />Many resources to learn to use it and a professional support are available<br />A product probably far from being perfect but on rails for the future<br />Many things to do<br />We need you !<br />
  98. 98. Questions ?<br />Apache Maven<br />
  99. 99. Licence et copyrights<br />Photos and logos belong to their respective authors/owners<br />Content underCreative Commons 3.0<br />Attribution — You must attribute the work in the mannerspecified by the author or licensor (but not in anywaythatsuggeststhattheyendorseyou or your use of the work).<br />Noncommercial — You may not use thiswork for commercial purposes.<br />ShareAlike — If you alter, transform, or builduponthiswork, youmaydistribute the resultingworkonlyunder the same or similarlicense to this one.<br />http://creativecommons.org/licenses/by-nc-sa/3.0/us/<br />
  1. A particular slide catching your eye?

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

×