Tips & Tricks April 8, 2011 Mickaël Tricot "FRIDAY"
From Maven 2 to Maven 3 <ul><ul><li>Maven 3 released in October 2010 </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Backwa...
Repositories <ul><ul><li>Repository in Europe:   http://uk.maven.org/maven2/ </li></ul></ul><ul><ul><li>  </li></ul></ul><...
Dependencies <ul><ul><li>&quot;When you have a set of projects that inherits a common parent it's possible to put all info...
Plugins <ul><ul><li>Root POM  <pluginManagement>   </li></ul></ul><ul><ul><ul><li>specifies  <groupId>, <artifactId>, <ver...
Properties <ul><ul><li>Use properties for values which </li></ul></ul><ul><ul><ul><li>might change in the future </li></ul...
Options <ul><ul><li>Debug mvn install -X </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Work offline: -o, --offline mvn in...
Help plugin <ul><ul><li>Display the effective POM </li></ul></ul><ul><ul><li>mvn help:effective-pom </li></ul></ul>
Dependency plugin <ul><ul><li>Show the dependencies which are used and undeclared or unused and declared /! </li></ul></ul...
Versions plugin <ul><ul><li>Report dependencies with newer versions available /! </li></ul></ul><ul><ul><li>mvn versions:d...
Convention over configuration <ul><li>   </li></ul><ul><li>&quot;Do not be smart!&quot; </li></ul><ul><li>  </li></ul>
Resources <ul><ul><li>Sonatype book http://www.sonatype.com/books/maven-book/   </li></ul></ul><ul><li>  </li></ul><ul><ul...
Upcoming SlideShare
Loading in...5
×

Maven - Tips & tricks

7,234

Published on

Published in: Technology, Art & Photos

Transcript of "Maven - Tips & tricks"

  1. 1. Tips & Tricks April 8, 2011 Mickaël Tricot &quot;FRIDAY&quot;
  2. 2. From Maven 2 to Maven 3 <ul><ul><li>Maven 3 released in October 2010 </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Backward compatibility... but </li></ul></ul><ul><ul><ul><li>Maven 1 repositories no longer supported </li></ul></ul></ul><ul><ul><ul><li>A few side effects may happen </li></ul></ul></ul><ul><li>  </li></ul><ul><ul><li>&quot;Harder better faster stronger&quot; </li></ul></ul><ul><ul><ul><li>Stricter: all plugin versions required </li></ul></ul></ul><ul><ul><ul><li>Faster: multithreaded, multicore </li></ul></ul></ul>
  3. 3. Repositories <ul><ul><li>Repository in Europe: http://uk.maven.org/maven2/ </li></ul></ul><ul><ul><li>  </li></ul></ul><ul><ul><li>  </li></ul></ul><ul><li>  </li></ul><ul><li>  </li></ul><ul><li>  </li></ul><ul><ul><li>Search engine: http://mavencentral.sonatype.com/ </li></ul></ul>
  4. 4. Dependencies <ul><ul><li>&quot;When you have a set of projects that inherits a common parent it's possible to put all information about the dependency in the common POM and have simpler references to the artifacts in the child POMs.&quot; </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Root POM <dependencyManagement>   </li></ul></ul><ul><ul><ul><li>specifies <groupId>, <artifactId>, <version>, <scope>, <exclusions> ... </li></ul></ul></ul><ul><ul><li>Module POMs <dependencies>   </li></ul></ul><ul><ul><ul><li>should only specify <groupId> , <artifactId> </li></ul></ul></ul>
  5. 5. Plugins <ul><ul><li>Root POM <pluginManagement>   </li></ul></ul><ul><ul><ul><li>specifies <groupId>, <artifactId>, <version> </li></ul></ul></ul><ul><ul><ul><li>common <configuration> ... </li></ul></ul></ul><ul><ul><li>Module POMs <dependencies>   </li></ul></ul><ul><ul><ul><li>should only specify <groupId> , <artifactId>   </li></ul></ul></ul><ul><ul><ul><li>specific <configuration> </li></ul></ul></ul>
  6. 6. Properties <ul><ul><li>Use properties for values which </li></ul></ul><ul><ul><ul><li>might change in the future </li></ul></ul></ul><ul><ul><ul><li>are used in several places </li></ul></ul></ul><ul><ul><li>Like </li></ul></ul><ul><ul><ul><li>All dependency and plugin versions </li></ul></ul></ul><ul><ul><ul><li>Some settings </li></ul></ul></ul><ul><li>  </li></ul><ul><ul><li>  Some properties are already built-in <project.build.sourceEncoding>   UTF-8 </project.build.sourceEncoding> </li></ul></ul><ul><li>  </li></ul>
  7. 7. Options <ul><ul><li>Debug mvn install -X </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Work offline: -o, --offline mvn install -o </li></ul></ul><ul><ul><li>Specify reactor projects: -pl, --projects mvn install -pl data,services,web </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Thread count : -T, --threads mvn install -T2C (2 threads per core ) </li></ul></ul>
  8. 8. Help plugin <ul><ul><li>Display the effective POM </li></ul></ul><ul><ul><li>mvn help:effective-pom </li></ul></ul>
  9. 9. Dependency plugin <ul><ul><li>Show the dependencies which are used and undeclared or unused and declared /! </li></ul></ul><ul><ul><li>mvn dependency:analyze </li></ul></ul><ul><ul><li>Resolve dependencies/plugins/reports before going offline </li></ul></ul><ul><ul><li>mvn dependency:go-offline </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Display the dependency tree </li></ul></ul><ul><ul><li>mvn dependency:tree -Dincludes=javax.jcr </li></ul></ul>
  10. 10. Versions plugin <ul><ul><li>Report dependencies with newer versions available /! </li></ul></ul><ul><ul><li>mvn versions:display-dependency-updates </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Report plugins with newer versions available </li></ul></ul><ul><ul><li>mvn versions:display-plugin-updates </li></ul></ul><ul><ul><li>  </li></ul></ul><ul><ul><li>Set the project version </li></ul></ul><ul><ul><li>mvn versions:set -DnewVersion=1.2 </li></ul></ul><ul><li>  </li></ul>
  11. 11. Convention over configuration <ul><li>  </li></ul><ul><li>&quot;Do not be smart!&quot; </li></ul><ul><li>  </li></ul>
  12. 12. Resources <ul><ul><li>Sonatype book http://www.sonatype.com/books/maven-book/ </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Maven 3 compatibility notes http://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Repository in Europe http://uk.maven.org/maven2/   </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Search engine http://mavencentral.sonatype.com/ </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Help plugin http://maven.apache.org/plugins/maven-help-plugin/ </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Dependency plugin http://maven.apache.org/plugins/maven-dependency-plugin/ </li></ul></ul><ul><li>  </li></ul><ul><ul><li>Versions plugin http://mojo.codehaus.org/versions-maven-plugin/ </li></ul></ul>

×