Build Numbers in jars build with Maven
Build Numbers for Maven builds using Cruise Control.
Maven is a very useful tool. For the most part, you can get it to do whatever you want, but the trick is finding out how. One issue that my team had was:
- We’re using Cruise Control
- We’d like to have the CC build number in the Jar Manifests
- We’re using Maven to build.
There are a couple of ways that you could do this, using ant from within maven, but that seems like extra work or at least extra complexity. The solution we found was:
Configure the project POM file to add a manifest to the jar. Most of the following is just using the maven Plugin. There is a great guide to manifests on the maven site so I’ll only show the parts relevant to configuring the manifest to add a cruise control build number.```
org.apache.maven.plugins
maven-jar-plugin
com.berczuk.ManifestDemo
com.berczuk
true
${build.number}
```by adding the line -Dbuild.number=${label}
you can pass the CC label for the build on to maven.