0
Introduction to project industrialization using Maven YaJUG 06/10/2009 Copyright © Pierre-Antoine Grégoire License Creativ...
Event <ul><ul><li>http://www.yajug.lu </li></ul></ul><ul><ul><li>October 06 2009  Best Practices and Tools for your build ...
Speaker <ul><li>Pierre-Antoine Grégoire </li></ul><ul><li>I.T.Architect at </li></ul><ul><li>Occasional committer in open ...
Who are you? <ul><li>Who in the audience is currently coding at work? </li></ul><ul><li>Who in the audience is managing th...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
Software development is engineering <ul><li>Since the early days of modern engineering, automation of build processes has ...
Software development is engineering <ul><li>How do you really enable automation of build? </li></ul><ul><ul><li>Build has ...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
A bit of history <ul><li>Software craftmens are lazy, so they are looking for efficiency (or the other way around… ) </li>...
A bit of history <ul><li>A simple script (.sh, .bat) is already a possible solution </li></ul><ul><li>More advanced comman...
A bit of history <ul><li>Two main categories in current tools </li></ul><ul><li>Scripting tools </li></ul><ul><ul><li>Ant ...
A bit of history <ul><li>Maven 1.x is now a 10 years old project, mostly motionless since 2007 (no insult intended to peop...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
Why Maven? <ul><li>Nowadays, build tools are not really used by developers directly. </li></ul><ul><li>IDEs are increasing...
Why Maven? <ul><li>If you are not already using it: </li></ul><ul><ul><li>Now is the best moment to start being aware </li...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
An introduction to Maven <ul><li>Maven 2 is a tool with multiple facets: </li></ul><ul><ul><li>a BUILD tool </li></ul></ul...
An introduction to Maven Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0 Project Object Model pom.xml mvn...
An introduction to Maven <ul><li>A project can easily be cut into modules thanks to Maven 2 </li></ul><ul><li>By simply de...
An introduction to Maven <ul><li>Project Object Model (POM) </li></ul><ul><ul><li>Basic project information </li></ul></ul...
An introduction to Maven <ul><li>A plug-in is made of a MOJO (Maven POJO) which is simply a java class with Maven-specific...
An introduction to Maven Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0 Lifecycle Phase Plug-ins Mojos d...
An introduction to Maven <ul><li>When you invoke a phase, Maven 2 will go through all the phases until the one specified, ...
An introduction to Maven <ul><li>There are many more phases than in previous examples in the default lifecycle </li></ul><...
An introduction to Maven <ul><li>Dependencies: A blessing and a curse </li></ul><ul><li>Blessing:  </li></ul><ul><ul><li>a...
An introduction to Maven <ul><li>What really made Maven different from other builds systems in the first place? </li></ul>...
An introduction to Maven Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
An introduction to Maven <ul><li>Local repository: </li></ul><ul><ul><li>Local cache for  artifacts </li></ul></ul><ul><ul...
An introduction to Maven <ul><li>Corporate repository/proxy </li></ul><ul><ul><li>Very useful tool </li></ul></ul><ul><ul>...
An introduction to Maven <ul><li>Public repositories </li></ul><ul><ul><li>Good for dependencies’ harvesting </li></ul></u...
An introduction to Maven <ul><li>Other key features of Maven: </li></ul><ul><li>POM Inheritance/Aggregation </li></ul><ul>...
An introduction to Maven <ul><li>POM Inheritance vs. POM Aggregation </li></ul><ul><ul><li>POM Inheritance :  </li></ul></...
An introduction to Maven <ul><li>Project Archetypes </li></ul><ul><ul><li>You can build template projects and make them av...
An introduction to Maven <ul><li>Launching Tests </li></ul><ul><li>Maven 2 allows to launch various types of tests: </li><...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
Drawbacks of Maven <ul><li>If you don’t embrace the standardization brought by Maven 2, you’ll soon feel limited by Maven ...
Worst practices <ul><li>You want more drawbacks? GET MORE OF THEM! </li></ul><ul><li>Use  maven-antrun-plugin  a lot! </li...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
Best practices <ul><li>They will allow you to overcome Maven 2’s drawbacks </li></ul><ul><li>Embrace the standardization b...
Best practices <ul><li>Don’t use Maven’s integrated reporting anymore </li></ul><ul><ul><li>It was meant for Apache projec...
Best practices <ul><li>If you provide a standard environment, try to make Maven plugins have a match in the IDE </li></ul>...
Best practices <ul><li>Documentation and information: </li></ul><ul><ul><li>Site  http://maven.apache.org </li></ul></ul><...
Best practices <ul><li>Books </li></ul><ul><ul><li>Free electronic editions: </li></ul></ul><ul><ul><li>Definitive Guide: ...
Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li>...
Maven 3.x Preview <ul><li>DISCLAIMER!!! </li></ul><ul><li>Everything mentioned here could end up being COMPLETELY FALSE!!!...
Maven 3.x Preview <ul><li>New release planned for this autumn/winter </li></ul><ul><li>Lots of refactorings of the insides...
Maven 3.x Preview <ul><li>Backward compatibility </li></ul><ul><ul><li>Loads of Integration testing is done to ensure back...
Maven 3.x Preview <ul><li>If you plan to migrate or want to evaluate: http://cwiki.apache.org/confluence/display/MAVEN/Mav...
Maven 3.x Preview <ul><li>What will be new to users: </li></ul><ul><ul><li>Versionless parent elements </li></ul></ul><ul>...
Maven in a Software development suite <ul><li>Maven is now very well integrated in IDEs </li></ul><ul><ul><li>NetBeans 6.5...
References and Thanks <ul><li>Many thanks to Arnaud Héritier </li></ul><ul><ul><li>He allowed me to be inspired by some of...
Upcoming SlideShare
Loading in...5
×

Introduction to project industrialization with Maven 2

2,906

Published on

Yajug 06102009

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,906
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
138
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to project industrialization with Maven 2"

  1. 1. Introduction to project industrialization using Maven YaJUG 06/10/2009 Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  2. 2. Event <ul><ul><li>http://www.yajug.lu </li></ul></ul><ul><ul><li>October 06 2009 Best Practices and Tools for your build environments </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  3. 3. Speaker <ul><li>Pierre-Antoine Grégoire </li></ul><ul><li>I.T.Architect at </li></ul><ul><li>Occasional committer in open source projects </li></ul><ul><li>Dislikes buzzwords (SOA, EDA…), likes to conceptualize and build architectures </li></ul><ul><li>Thinks having fun and working seriously (both at the same time) should be mandatory! </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  4. 4. Who are you? <ul><li>Who in the audience is currently coding at work? </li></ul><ul><li>Who in the audience is managing the lucky coders? </li></ul><ul><li>Who is already using Maven 2+? </li></ul><ul><li>Who is planning on using it and came to have more information? </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  5. 5. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  6. 6. Software development is engineering <ul><li>Since the early days of modern engineering, automation of build processes has been the key to: </li></ul><ul><ul><li>Productivity improvements </li></ul></ul><ul><ul><li>Quality insurance </li></ul></ul><ul><ul><li>Failure-Proofing </li></ul></ul><ul><li>Why would software development be any different? </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  7. 7. Software development is engineering <ul><li>How do you really enable automation of build? </li></ul><ul><ul><li>Build has to be reproducible </li></ul></ul><ul><ul><li>Build has to produce the final production artifact </li></ul></ul><ul><ul><li>Build has to be as easy to maintain as possible and well documented </li></ul></ul><ul><ul><li>Build has to contribute to the standardization effort </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  8. 8. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  9. 9. A bit of history <ul><li>Software craftmens are lazy, so they are looking for efficiency (or the other way around… ) </li></ul><ul><ul><li>One command line to launch for a build, OK </li></ul></ul><ul><ul><li>Two command lines to launch for a build, BAD enough </li></ul></ul><ul><ul><li>More… forget it… </li></ul></ul><ul><li>Disclaimer: I’m one of these lazy craftmen… </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  10. 10. A bit of history <ul><li>A simple script (.sh, .bat) is already a possible solution </li></ul><ul><li>More advanced command-line tools have been available for a long time </li></ul><ul><li>make created in 1977 at Bells Labs by Stuart Feldman </li></ul><ul><ul><li>Still very much used nowadays </li></ul></ul><ul><li>Apache Ant created by James Duncan Davidson </li></ul><ul><ul><li>Was at first a platform-independent build system for Tomcat because Sun’s build system for Servlet RI (From which Tomcat was derived) was specific to Solaris. </li></ul></ul><ul><ul><li>Released separately in 2000 </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  11. 11. A bit of history <ul><li>Two main categories in current tools </li></ul><ul><li>Scripting tools </li></ul><ul><ul><li>Ant and derived (XML) </li></ul></ul><ul><ul><li>Rake (Ruby based) </li></ul></ul><ul><ul><li>Gradle (Groovy based) </li></ul></ul><ul><ul><li>… many others </li></ul></ul><ul><li>Artifact oriented tools </li></ul><ul><ul><li>Maven </li></ul></ul><ul><ul><li>Debian Package Creation </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  12. 12. A bit of history <ul><li>Maven 1.x is now a 10 years old project, mostly motionless since 2007 (no insult intended to people still using it or committing to it) </li></ul><ul><li>Maven 2.x is the de facto standard for Java and Java EE build </li></ul><ul><ul><li>Most open source projects are switching to Maven for their build system </li></ul></ul><ul><ul><li>It’s now five years old </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  13. 13. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  14. 14. Why Maven? <ul><li>Nowadays, build tools are not really used by developers directly. </li></ul><ul><li>IDEs are increasing their functionalities scope, </li></ul><ul><ul><li>Compilation is almost always done on the fly </li></ul></ul><ul><ul><li>Package and server startup is monitored by rich Uis </li></ul></ul><ul><ul><li>Step-by-step debugging is a killer feature </li></ul></ul><ul><li>Build tools like Maven 2 are used to build the package you will put into production! This should never be done by an IDE, nor by hand! </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  15. 15. Why Maven? <ul><li>If you are not already using it: </li></ul><ul><ul><li>Now is the best moment to start being aware </li></ul></ul><ul><ul><li>Maven is mature </li></ul></ul><ul><ul><li>Maven is getting better and better </li></ul></ul><ul><ul><li>Maven can be used online, offline, and in enterprise environment </li></ul></ul><ul><li>If you are already using it: </li></ul><ul><ul><li>Hang on! The best is yet to come! </li></ul></ul><ul><ul><li>Focus on necessary things and don’t get frustrated by petty details </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  16. 16. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  17. 17. An introduction to Maven <ul><li>Maven 2 is a tool with multiple facets: </li></ul><ul><ul><li>a BUILD tool </li></ul></ul><ul><ul><li>a DEPENDENCY MANAGEMENT tool </li></ul></ul><ul><ul><li>a DOCUMENTATION tool </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  18. 18. An introduction to Maven Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0 Project Object Model pom.xml mvn Generated artifacts (jar, war, ear…) , Documentation, statistics (test results, quality metrics, javadoc, web site) …
  19. 19. An introduction to Maven <ul><li>A project can easily be cut into modules thanks to Maven 2 </li></ul><ul><li>By simply declaring project metadata and optionally configuring a few plug-ins, you can: </li></ul><ul><ul><li>Build your project (compile, generate sources …) </li></ul></ul><ul><ul><li>Launch tests and gather results (Junit, TestNG, Selenium…etc) </li></ul></ul><ul><ul><li>Package (Jar, War, Ejb, War…etc) </li></ul></ul><ul><ul><li>Document and generate reports </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  20. 20. An introduction to Maven <ul><li>Project Object Model (POM) </li></ul><ul><ul><li>Basic project information </li></ul></ul><ul><ul><ul><li>groupId, artifactId, version… </li></ul></ul></ul><ul><ul><ul><li>Inheritance, or Aggregation through sub-modules (we’ll explain the difference later on) </li></ul></ul></ul><ul><ul><li>Build section </li></ul></ul><ul><ul><ul><li>Project layout (sources and resources folders… etc) </li></ul></ul></ul><ul><ul><ul><li>Build plugins configuration </li></ul></ul></ul><ul><ul><li>Reporting section </li></ul></ul><ul><ul><ul><li>Reports configuration </li></ul></ul></ul><ul><ul><li>Some other advanced environment settings </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  21. 21. An introduction to Maven <ul><li>A plug-in is made of a MOJO (Maven POJO) which is simply a java class with Maven-specific metadata. </li></ul><ul><li>A plug-in can define goals and reports </li></ul><ul><li>Goals can be called directly: </li></ul><ul><ul><li>mvn plugin:goal </li></ul></ul><ul><li>Goals can be bound to one or multiple phases </li></ul><ul><li>Reports are used during site generation </li></ul><ul><ul><li>mvn site </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  22. 22. An introduction to Maven Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0 Lifecycle Phase Plug-ins Mojos define Goals (fine grained tasks) mojo mojo mojo mojo mojo
  23. 23. An introduction to Maven <ul><li>When you invoke a phase, Maven 2 will go through all the phases until the one specified, executing the bound goals: </li></ul><ul><ul><li>mvn package </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0 compiler:compile s urefire:test j ar:jar
  24. 24. An introduction to Maven <ul><li>There are many more phases than in previous examples in the default lifecycle </li></ul><ul><li>By default, all the basic necessary plug-ins for the build phase are already bound to phases </li></ul><ul><li>It is easy to have information about plugins: </li></ul><ul><ul><li>mvn help:describe </li></ul></ul><ul><li>So….. what’s left to do, and what’s all the fuss about the complexity of Maven 2? </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  25. 25. An introduction to Maven <ul><li>Dependencies: A blessing and a curse </li></ul><ul><li>Blessing: </li></ul><ul><ul><li>almost all java build tools nowadays leverage the Maven 2 repositories (cf. Ivy, Ant, Gradle…etc) </li></ul></ul><ul><ul><li>easier to find/discover/use java libraries </li></ul></ul><ul><li>Curse: </li></ul><ul><ul><li>Transitive dependencies can rapidly trigger a dependency hell! </li></ul></ul><ul><ul><li>Curse: Harder to stabilize builds </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  26. 26. An introduction to Maven <ul><li>What really made Maven different from other builds systems in the first place? </li></ul><ul><li>REPOSITORIES !!! </li></ul><ul><li>Before Maven, it was really hard to find java libraries, and harder to ensure a coherent use of these libraries (I’m saying hard, not impossible…) </li></ul><ul><li>Nowadays, it’s still very hard to find some jars with a decent/coherent versioning (discretely winking in the general direction of Sun participants...), let alone to find their sources or javadocs </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  27. 27. An introduction to Maven Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  28. 28. An introduction to Maven <ul><li>Local repository: </li></ul><ul><ul><li>Local cache for artifacts </li></ul></ul><ul><ul><li>Local private sandbox </li></ul></ul><ul><ul><li>It should be possible to erase it regularly </li></ul></ul><ul><ul><li>Very useful for offline builds </li></ul></ul><ul><li>By default in user home’s .m2/ folder </li></ul><ul><li>Can be moved to another place through Maven 2 runtime’ settings.xml file </li></ul><ul><li>$MAVEN_HOME/conf/settings.xml </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  29. 29. An introduction to Maven <ul><li>Corporate repository/proxy </li></ul><ul><ul><li>Very useful tool </li></ul></ul><ul><ul><li>The first necessary step towards a corporate use of maven </li></ul></ul><ul><li>Can be as simple as a corporate http server exposing a repository </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0 <ul><li>Even better: install a repository management tool </li></ul><ul><ul><li>Can proxy external repositories </li></ul></ul><ul><ul><li>Can filter unwanted artifacts </li></ul></ul><ul><ul><li>Build even without internet access! (well… at least for the repository management tool) </li></ul></ul>
  30. 30. An introduction to Maven <ul><li>Public repositories </li></ul><ul><ul><li>Good for dependencies’ harvesting </li></ul></ul><ul><ul><li>Should be proxied in corporate environments… or even for your personal use! </li></ul></ul><ul><ul><li>A lot of mis-configured dependencies </li></ul></ul><ul><ul><li>A lot of alpha/beta Maven 2 plug-ins </li></ul></ul><ul><li>Be cautious when adding public repositories to a build process! </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  31. 31. An introduction to Maven <ul><li>Other key features of Maven: </li></ul><ul><li>POM Inheritance/Aggregation </li></ul><ul><li>Archetypes </li></ul><ul><li>Launching Tests </li></ul><ul><li>… many more… </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  32. 32. An introduction to Maven <ul><li>POM Inheritance vs. POM Aggregation </li></ul><ul><ul><li>POM Inheritance : </li></ul></ul><ul><ul><ul><li>a POM and all its parent POMs will be flattened at runtime </li></ul></ul></ul><ul><ul><ul><li>In the end only one effective POM in memory </li></ul></ul></ul><ul><ul><ul><li>This is mostly used to share common configuration </li></ul></ul></ul><ul><ul><li>POM Aggregation : </li></ul></ul><ul><ul><ul><li>declare modules in a given project </li></ul></ul></ul><ul><ul><ul><li>If a command is issued against a project, it will be also issued against all its modules </li></ul></ul></ul><ul><ul><ul><li>This is mostly used to organize builds and gather projects that should be built simultaneously </li></ul></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  33. 33. An introduction to Maven <ul><li>Project Archetypes </li></ul><ul><ul><li>You can build template projects and make them available as artifacts in the repositories </li></ul></ul><ul><ul><li>Allows to share best practices without neither inheritance nor aggregation </li></ul></ul><ul><ul><ul><li>mvn archetype:create-from-project </li></ul></ul></ul><ul><ul><ul><li>mvn archetype:generate </li></ul></ul></ul><ul><ul><li>Many Archetypes already configured in the default catalog </li></ul></ul><ul><ul><li>You can easily build a custom or corporate catalog </li></ul></ul><ul><ul><ul><li>mvn archetype:generate </li></ul></ul></ul><ul><ul><ul><li>– DarchetypeCatalog=http://www.corporate.com/archetypes.xml </li></ul></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  34. 34. An introduction to Maven <ul><li>Launching Tests </li></ul><ul><li>Maven 2 allows to launch various types of tests: </li></ul><ul><ul><li>Unit tests: Junit 3.x or 4.x, TestNG, … </li></ul></ul><ul><ul><li>UI Tests: Selenium, Canoo Webtest </li></ul></ul><ul><ul><li>Functional tests: Fitnesse, Greenpepper </li></ul></ul><ul><ul><li>WebServices tests: SOAPUi </li></ul></ul><ul><ul><li>And many more… </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  35. 35. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  36. 36. Drawbacks of Maven <ul><li>If you don’t embrace the standardization brought by Maven 2, you’ll soon feel limited by Maven 2 </li></ul><ul><li>Additionally, standardization can be quite expensive! Measure the implied cost by testing on 2 subsequent projects (one to absorb the POC effect, and one for measure) </li></ul><ul><li>By default Maven 2 has its own folder structure normalization, unknown to IDEs (though this is not completely true anymore) </li></ul><ul><li>Last but not least: Maven 2 error reporting is SO BAAAAD! </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  37. 37. Worst practices <ul><li>You want more drawbacks? GET MORE OF THEM! </li></ul><ul><li>Use maven-antrun-plugin a lot! </li></ul><ul><ul><li>So coool, this way you can use Maven and not Ant! </li></ul></ul><ul><li>Build very intricated projects with modules having modules themselves, and lots of inheritances all around! </li></ul><ul><ul><li>Niiice! This allows you to spend more time with your favorite tool: Maven 2 in order to find out where your damn properties/dependencies are defined! </li></ul></ul><ul><li>Replace your IDE with Maven and try to add all of your IDE’s functionalities as Maven plugins!!!!! </li></ul><ul><ul><li>You got my point ;) </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  38. 38. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  39. 39. Best practices <ul><li>They will allow you to overcome Maven 2’s drawbacks </li></ul><ul><li>Embrace the standardization brought by Maven 2, don’t fight it </li></ul><ul><li>Use POM Inheritance and <dependencyManagement> (with import scope) , <pluginManagement> to tame the transitive dependencies. (don’t mistake these for <dependencies> , <plugins>… ) </li></ul><ul><li>Use a Repository Manager: </li></ul><ul><ul><li>Sonatype Nexus: http://nexus.sonatype.org </li></ul></ul><ul><ul><li>Jfrog Artifactory: http://artifactory.jfrog.org </li></ul></ul><ul><ul><li>… </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  40. 40. Best practices <ul><li>Don’t use Maven’s integrated reporting anymore </li></ul><ul><ul><li>It was meant for Apache project’s web sites static documentation </li></ul></ul><ul><ul><li>The amount of time spent in order to build them is not worth it in enterprise environment </li></ul></ul><ul><li>Keep your build as simple as possible </li></ul><ul><li>Generate test statistics data and other metrics data in order to exploit them in Software quality tools: </li></ul><ul><ul><li>Sonar: http://sonar.codehaus.org </li></ul></ul><ul><ul><li>Squale: http://www.squale.org </li></ul></ul><ul><ul><li>… </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  41. 41. Best practices <ul><li>If you provide a standard environment, try to make Maven plugins have a match in the IDE </li></ul><ul><ul><li>If Maven 2 launches Checkstyle, provide the Checkstyle Eclipse plugin to your projects. </li></ul></ul><ul><li>Launch your builds regularly and possibly in a neutral zone (not on the developer’s desktop!) in order to ensure “rule number one” is respected: Build must be reproducible. </li></ul><ul><li>Use the “dependency” and “versions” plugins to handle dependencies and diagnose dependencies mismatches or errors </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  42. 42. Best practices <ul><li>Documentation and information: </li></ul><ul><ul><li>Site http://maven.apache.org </li></ul></ul><ul><ul><li>Plugins </li></ul></ul><ul><ul><ul><li>http://maven.apache.org/plugins </li></ul></ul></ul><ul><ul><ul><li>http://mojo.codehaus.org/ </li></ul></ul></ul><ul><ul><ul><li>http://code.google.com/ </li></ul></ul></ul><ul><ul><ul><li>And many others… </li></ul></ul></ul><ul><ul><li>Project Wiki http://docs.codehaus.org/display/MAVEN/ </li></ul></ul><ul><ul><li>Users’ Wiki http://docs.codehaus.org/display/MAVENUSER </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  43. 43. Best practices <ul><li>Books </li></ul><ul><ul><li>Free electronic editions: </li></ul></ul><ul><ul><li>Definitive Guide: http://www.sonatype.com/books </li></ul></ul><ul><ul><li>Better Builds with Maven: http://www.maestrodev.com/better-build-maven </li></ul></ul><ul><ul><li>Upcoming book by Arnaud Héritier and Nicolas De Loof </li></ul></ul><ul><ul><li>http://www.pearson.fr/livre/?GCOI=27440100730370 </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  44. 44. Planning <ul><li>Software development is engineering </li></ul><ul><li>A bit of history </li></ul><ul><li>Why Maven? </li></ul><ul><li>An introduction to Maven </li></ul><ul><li>Drawbacks of Maven </li></ul><ul><li>Best practices </li></ul><ul><li>Maven 3.x preview </li></ul><ul><li>Maven in a Software development suite </li></ul>Textual content under Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  45. 45. Maven 3.x Preview <ul><li>DISCLAIMER!!! </li></ul><ul><li>Everything mentioned here could end up being COMPLETELY FALSE!!! (though project is now well advanced) </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  46. 46. Maven 3.x Preview <ul><li>New release planned for this autumn/winter </li></ul><ul><li>Lots of refactorings of the insides of Maven 2 </li></ul><ul><ul><li>Not immediately obvious (in a way this is better than the complete product change between Maven 1 and 2) </li></ul></ul><ul><ul><li>Will allow to tackle upcoming challenges and regular issues of Maven 2 in a more elegant manner </li></ul></ul><ul><ul><li>Simplifies plug-in development </li></ul></ul><ul><li>Efficient embedder </li></ul><ul><ul><li>Maven 2 has lots of singletons and such and is therefore improper for use in multithreaded environments (CIM, IDE) </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  47. 47. Maven 3.x Preview <ul><li>Backward compatibility </li></ul><ul><ul><li>Loads of Integration testing is done to ensure backwards compatibility </li></ul></ul><ul><ul><li>Stricter validation of the POM </li></ul></ul><ul><ul><li>Configured plugins should have their versions specified (a warning appears otherwise) </li></ul></ul><ul><li>Site/reporting is now completely extracted from the Maven core </li></ul><ul><ul><li>Currently the Site plugin doesn’t work with Maven 3, yet should until the final release (though reports still work) </li></ul></ul><ul><ul><li>Recommended to switch to the use of external quality monitoring tools </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  48. 48. Maven 3.x Preview <ul><li>If you plan to migrate or want to evaluate: http://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes </li></ul><ul><li>Presentation by Jason van Zyl (Sonatype) http://www.scribd.com/doc/14458957/Jasons-Maven-3-Presentation </li></ul><ul><li>My first impressions: </li></ul><ul><ul><li>Maven 3 looks awesome! </li></ul></ul><ul><ul><li>Embedder is a killer feature </li></ul></ul><ul><ul><ul><li>The IDE can literally listen for the Build process, and be part of it, not just launch it. </li></ul></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  49. 49. Maven 3.x Preview <ul><li>What will be new to users: </li></ul><ul><ul><li>Versionless parent elements </li></ul></ul><ul><ul><li>Better version delegation </li></ul></ul><ul><ul><li>Better error and integrity reporting </li></ul></ul><ul><ul><li>XML Pom format using attributes instead of elements </li></ul></ul><ul><ul><li>Scripted POM Formats (pom.{rb|groovy|py}) </li></ul></ul><ul><li>What will be new to plugin developers: </li></ul><ul><ul><li>Plugin extension points </li></ul></ul><ul><ul><li>Annotations instead of old javadoc tags </li></ul></ul><ul><ul><li>Lifecycle extension points </li></ul></ul><ul><ul><li>Queryable lifecycle </li></ul></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  50. 50. Maven in a Software development suite <ul><li>Maven is now very well integrated in IDEs </li></ul><ul><ul><li>NetBeans 6.5+ now has very good support for Maven 2 </li></ul></ul><ul><ul><li>Eclipse 3.x has very good support also, with preview of Maven 3.x embedder (blazingly fast!) </li></ul></ul><ul><ul><li>IntelliJ IDEA seems to have excellent support also (though this is why you pay for it isn’t it?) </li></ul></ul><ul><li>Maven works very well with Quality monitoring tools </li></ul><ul><li>Maven 3 will most likely increase the embedding of Maven and its use for other JVM Languages and possibly for other platforms </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  51. 51. References and Thanks <ul><li>Many thanks to Arnaud Héritier </li></ul><ul><ul><li>He allowed me to be inspired by some of its recent slides presented to the French Ch’ti JUG </li></ul></ul><ul><ul><li>http://blog.aheritier.net </li></ul></ul><ul><ul><li>He also was kind enough to review this presentation ;) </li></ul></ul><ul><li>Many thanks to Jason van Zyl for its Maven 3 presentation I was heavily inspired by </li></ul><ul><li>http://www.sonatype.com/people/author/jason </li></ul>Copyright © Pierre-Antoine Grégoire License Creative Commons 2.0
  1. A particular slide catching your eye?

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

×