I want to generate a properties file, from my ant script, that contains the svn version number of my project. I'm 1/3 of the way done:
To do this I need to:
use svnversion
1a. define the svn task
1b. use <svn><wcVersion></svn>
put the result in a .properties file that ends up in my build path
I'm a bit lost with 1a and 2. any ideas?
never mind, I got it working:
<target name="svnversion">
<echo file="${srcDir}/${packagePath}/svnversion.properties">svnversion=</echo>
<exec executable="svnversion"
output="${srcDir}/${packagePath}/svnversion.properties" append="true">
</exec>
</target>
What I used is to execute svn info --xml
, then loaded the resulted xml file using <XmlProperty>
task and in the end just replacing a token in the property file that is path of the build path.
So something like this:
<target name="svn-build-number">
<tempfile property="svninfo.file"/>
<exec dir="." executable="svn" output="${svninfo.file}">
<arg line="info --xml"/>
</exec>
<echo message="${svninfo.file}" />
<xmlproperty file="${svninfo.file}" collapseAttributes="true" />
<echo message="${info.entry.revision}" />
</target>
In ${info.entry.revision}
is the revision of the repository in the current dir.