2

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:

  1. use svnversion

    1a. define the svn task

    1b. use <svn><wcVersion></svn>

  2. 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?

Jason S
  • 178,603
  • 161
  • 580
  • 939

2 Answers2

6

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>   
Jason S
  • 178,603
  • 161
  • 580
  • 939
3

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.

martin clayton
  • 74,574
  • 30
  • 214
  • 196
fikovnik
  • 3,293
  • 2
  • 27
  • 29