Information about Maven2 and its use with Topaz

See Also: DevSetup

Topaz and Ambra utilise Maven2 for building the appropriate packages. It would help to read some of the background material on maven. NOTE: Some of this information is out of date, but provides a decent background.

Maven makes extensive use of plug-ins to perform various tasks and documentation is typically at the plugin site rather than the main maven site. A web search using 'maven plugin <plugin-name>' should lead to the appropriate plugin site and documenation.

Structuring of Topaz pom.xml

  • Main GroupId?: org.topazproject, Topaz Artifact prefix: topaz, Ambra Artifact prefix: org.topazproject.ambra
  • Please put plugin and dependency version string explicitly in top level pom. This ensures that builds can be reproduced reliably
  • Builds get deployed to Topaz Maven Repository

Maven Repository on http://maven.topazproject.org/maven2

To install 3rd party jar/war/tar/zip files in our repository do something like this:

  export MAVEN_OPTS='-Xmx512M'
  
  mvn deploy:deploy-file -DgroupId=info.fedora
  -DartifactId=client-distribution -Dversion=2.1.1 -Dpackaging=tar
  -Dfile=/home/fedora/fedora-2.1.1-client.tar -DrepositoryId=topaz
  -Durl=http://maven.topazproject.org/maven2

  mvn deploy:deploy-file -DgroupId=info.fedora
  -DartifactId=server-distribution -Dversion=2.1.1 -Dpackaging=tar
  -Dfile=/home/fedora/fedora-2.1.1-server.tar -DrepositoryId=topaz
  -Durl=http://maven.topazproject.org/maven2

  mvn deploy:deploy-file -DgroupId=info.fedora
  -DartifactId=diringest-distribution -Dversion=2.1.1 -Dpackaging=zip
  -Dfile=/home/fedora/diringest-service.zip -DrepositoryId=topaz
  -Durl=http://maven.topazproject.org/maven2

Please see Maven Deployment Plugin for various available options.

Note that deploying large files causes maven to abort with java.lang.OutOfMemoryError. So set up a larger heap-size using MAVEN_OPTS as shown above.

Also note that you need to add a section in your ~/.m2/settings.xml:

  <servers>
    <server>
      <id>topaz</id>
      <username>not your maven.topazproject.org login; please ask</username>
      <password>**********</password>
    </server>
  </servers>

Best Practises

  • Do not use per-plugin dependencies. The problem with these is that maven currently will only set up those dependencies defined in the first instance of that plugin that it encounters. This leads to inconsistence builds as it depends on which directory you build from. If per-plugin dependencies are really needed for some plugin, then define them in a <pluginManagement> section in the top-level pom.
  • Do not put project dependencies in a per-plugin dependency section. E.g. if the antrun plugin is used to build something, put the dependencies that it uses for building into the normal project dependencies section, not in the per-plugin dependency (after all, the jars used for compiling the sources are not configured as dependencies of the compiler plugin either). However, if you use, say, the antcontrib library in the ant script then that would be defined as a dependency on the antrun plugin itself (but see the above point).
  • Do not put <scope>'s in the <dependencyManagment> section; the possible exception is scope 'test'. This is because it can lead to interesting surprises otherwise.
  • Use the gant plugin (groovy-maven-plugin) whenever you feel like using antrun plugin - the control structures, variables, etc make this much easier to use than ant.
  • Configure additional repositories sparingly, especially in the top-level pom. These can slow down the build noticeably when maven goes to the repositories for updates (this doesn't affect 'mvn -o', of course).

Attachments