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.
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.
<plugin>This will set a buildNumber field in the manifest to the value of the build.number property. The trick is to get the property into maven. To do this you take advantage of the properties that cruise control makes available to you. I am using the cruise control AntBuilder to launch maven. So my cruise control config.xml looks like:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.berczuk.ManifestDemo</mainClass>
<packageName>com.berczuk</packageName>
<addClasspath>true</addClasspath>
<addExtensions />
</manifest>
<manifestEntries>
<buildNumber>${build.number}</buildNumber>
</manifestEntries>
</archive>
</configuration>
</plugin>
<ant antscript="/usr/local/ant/bin/ant"Implicitly, CruiseControl makes some properties available to you:
buildfile="checkout/demo/build.xml"
uselogger="true" usedebug="true" target="cruisecontrol.build">
<property name="maven.path" value="/usr/local/maven2/bin/mvn"/>
</ant>
<target name="cruisecontrol.build" depends="cvsUpdate">by adding the line
<mkdir dir="target" />
<exec executable="${maven.path}" dir="${basedir}" failonerror="true" output="build.out" logError="true">
<arg line="-Dbuild.number=${label} clean package assembly:assembly install" />
</exec>
</target>
-Dbuild.number=${label}
you can pass the CC label for the build on to maven.