We have previously discussed getting the subversion revision number from an ant script. While the previous method relied on antcontrib and regexes, I’ve recently come across the SvnAnt project.
SvnAnt is a contribution for ant, which allows for access to svn functionality from within your ant scripts. Several of the svn operations are available, and are documented here. Personally, I think that your build system shouldn’t be mucking around with your source control system, though it is useful to use the subversion revision number as part of your build numbering system.
<target name="find_revision" description="Sets property 'svn.info.lastRev' to head svn revision">
<path id="svnant.libs.path>
<fileset dir="libs">
<include name="svnant.jar"/>
<include name="svnClientAdapter.jar"/>
</fileset>
</path>
<!-- Load SvnAnt -->
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.libs.path" />
<!-- find head revision number, amongst other things. -->
<!-- Replace svn_username and svn_password with values appropriate to your system -->
<svn username="svn_username" password="svn_password" javahl="false">
<info target="." />
</svn>
<!-- Display svn revision number -->
<echo>Revision found: ${svn.info.lastRev}</echo>
</target>