Reputation: 977
For an Ant extension we have a Java class which retrieves the highest svnrevision number in a local working copy. The class already supports up to SVN 1.6 but we have to change it to support SVN 1.7 using the local wc.db. I have googled some time now on this subject, but cannot find a clear hint how to solve this.
Is there any example code available how to retrieve the revision number from a SVN 1.7 working copy, equivalent to what the svnversion binary does ?
Cheers Peter
Upvotes: 1
Views: 3003
Reputation: 11946
SVNKit, the only Java SVN API I know, only supports Subversion 1.6.5. But maybe the feature you are looking for is already working? It's worth to give it a try, imo.
Upvotes: 1
Reputation: 5949
Parsing subversion metainfo in order to get latest revision number IMHO is not a good idea.
Actually, there is another standard way of getting revision number. You could use svn:keywords
in order to get current revision number in your files after each commit. There is $Revision$
property for revision substitution. You just need to put following string into the file and place this file under version control:
$Revision$
If you need to use revision property in ant, I would recommend putting following content into version.properties file:
revision=$Revision$
Then include in into the build.xml
with the statement:
<property file="build.properties"/>
And then you will be able to use revision number in your build script:
<echo message="Deploying revision ${revision}" />
Please also note that you will need to explicitly enable svn:keywords
using subversion properties in order to get $Revision$
substituted in your file with actual value. If you use version.properties
for getting revision number value, you will need to run following command:
svn propset svn:keywords Revision version.properties
Not sure that will work for your case, but that's the approach I use most often in my projects if I want to use revision number during the build process. This approach is definitely better than getting revision number from the working copy metainfo.
Upvotes: 1
Reputation: 97467
Was SVNKit too simple: SVNKit alpha version supports already SVN 1.7 working copy format...so just give it a try...
Upvotes: 0