Using ant svn task to get working copy version?

Is there a way to use the svn ant task to get the svn version number for the working copy and put it in a variable?

I would like to add an entry to my Java manifest file that includes the svn version number, eg. 0.9.65361

where 65361

is the revision number.

+4


source to share


3 answers


Yep, I found this idea which only depends on the command line utility svnversion

in SVN.

<project name="ant-exec-example" default="svnversion" basedir=".">
  <target name="svnversion">
    <exec executable="svnversion" outputproperty="svnversion" />
    <echo message="SVN Version: ${svnversion}"/>
  </target>
</project>

      



Here's where it grabs the version in the ant property:

<exec executable="svnversion" outputproperty="svnversion" />

      

+6


source


There are several ways -



  • Using a utility - I believe you are looking for this - https://code.google.com/p/svntask/ I have used it for some side projects and it works well.

  • Use a command line utility. - "svn info http://svn.myweb.com/myproject ". To use this method, simply create a batch file and place this command in the batch file. Then name this batch file from your ant task and get the version number from the text by searching that starts with the line "Revision:". Or you can simply upload the entire result.

0


source


Here is my option for combining SVN version information into an application artifact:

<target name="svn_revisions">
    <exec dir="${basedir}" executable="svn" output="${dir.out}/.revisions">
        <arg line="info"/>
    </exec>
    <exec dir="${basedir}" executable="svn" output="${dir.out}/.revisions" append="true">
        <arg line="status -u"/>
    </exec>
</target>

<target name="build-war" depends="compile, svn_revisions">
    <war basedir="web" file="${dir.out}/ROOT.war" webxml="web/WEB-INF/web.xml">
        <!-- main stuff -->
        <zipfileset dir="${dir.out}" prefix="META-INF" includes=".revisions"/>
    </war>
</target>

      

0


source







All Articles