Get the current SVN revision number in from Ant

Another minor Problem I struggled with the last couple times I was updating one of my build scripts was resolving the current SVN revision number from within ant. Google points out a few solutions, but most of them require optional SVN tasks or do an exec. Someone (sorry, I would put a link if I could remember) came up with the simple solution of using the stored SVN information from the filesystem. So:

    <loadfile property="svn.revision" srcFile="./.svn/entries">
        <filterchain>
        <headfilter lines="1" skip="3"/>
        <deletecharacters chars="\n"/>
        </filterchain>
   </loadfile>

loads the current revision number into a property called svn.revision. I use this with svn 1.4 and 1.5 repositories and it works just fine.

Tags: ,

Thursday, May 14th, 2009 Other

2 Comments to Get the current SVN revision number in from Ant

  1. great !
    I was about to try SVNAnt just to get this revision number but your simple solution is perfect in my case :)

  2. emerix on March 28th, 2010
  3. Ferrari castle play go

  4. pletcherfte on May 23rd, 2012

Leave a comment