Does anyone have a simple suggestion for recording a build ID (generated at compile time) which is displayed in the title bar of the app at runtime?
Building from within Eclipse, all I need is the ID, I can then pass it up to the title.
If you're using Maven, especially if you want the build number from SVN (though it can generate unique build numbers for you through a configuration), look at the buildnumber-maven-plugin.
You simply add a snippet similar to the following to your pom.xml file:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<doUpdate>true</doUpdate>
</configuration>
</plugin>
Then use ${buildNumber} later on in your pom to refer to the build id. I use it to write that number to the manifest like so, using the maven-war-plugin.
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
</manifestEntries>
</archive>
If you are using Ant, you can easily set up your "jar" or "package" target so that it generates a file including the current timestamp and include this in your jar
output.
If using Maven, there are a few ways to achieve something similar, such as dropping down to Ant using the antrun plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With