Hi!
Lately I wanted to include the SNV repository revision number into my applications about box. As the search with Google was very time consuming and not very satisfactory I want to outline how I have solved this issue.
1. Download SVNAnt 1.1.0 RC2 from
http://subclipse.tigris.org/files/do...-1.1.0-RC2.zip
(Be sure you have Ant installed)
2. Install it as described in the README
3. In the source directory I've created an empty file called "BuildInfo.java" and checked it in into my repository.
4. In the Eclipse project I've created a new file in my source directory called "build.xml"
<!-- Generate a java class with the current svn revision number -->
<project>
<echo>Generate build info class...</echo>
<taskdef resource="svntask.properties" />
<svn>
<status path="${basedir}\BuildInfo.java" revisionProperty="svn.revision" />
</svn>
<tstamp>
<format property="TODAY" pattern="EEE, d-MMMM-yyyy HH:mm:ss z" locale="ENGLISH, GERMANY"/>
</tstamp>
<echo>Virtual PVT Cell Revision: ${svn.revision}</echo>
<echo>Time stamp ${TODAY}</echo>
<echo>Write build info to file ${basedir}\BuildInfo.java</echo>
<!-- the source code of the java class -->
<echo file="${basedir}\BuildInfo.java">
package gui;
public class BuildInfo {
public static final String revisionNumber="${svn.revision}";
public static final String timeStamp="${TODAY}";
}
</echo>
</project>
This ant script gets now the revision number form the file "BuildInfo.java" and creates a simple Java class that can be now included anywhere in the project. It may look like this:
package gui;
public class BuildInfo {
public static final String revisionNumber="451";
public static final String timeStamp="Mon, 21-April-2008 23:51:43 CEST";
}
Inlcude your BuildInfo.java in any source file and you can say e.g.
System.out.println(BuildInfo.revisionNumber);
5. To execute the script everytime before a build the following did the trick:
Project->Properties->Builder
Click New...
Select Ant Builder
As Build file set our "build.xml"
OK
Well that's it, basically. I hope it is helpful for someone.
sal_manilla