Running subversion with Ant can be a bit of a tedious process.
First it requires the three jars (svnant.jar, svnClientAdapter.jar,svnjavahl.jar) which need to be loaded. For ‘ant’ this can be done in two ways. Either you place all the jars in the ant lib directory. The other method is to load the jars when running ant via the command prompt.
ant -lib /home/svn/java/lib
with this one is setup to use svn with ant. Unfortunately that is not enough.
With the help of the underlying svnClientAdapter, <svn> task uses JavaHL (a native JNI interface to the subversion api) if it can find the corresponding library (e.g. svnjavahl.dll on windows). Otherwise it uses svn command line interface.
http://subclipse.tigris.org/svnant/svn.html
So now you are either have to have the native JNI interface or you have to have subversion installed in the system. I had subversion installed in my system.
So now we can move forward to the ant build file.
<typedef resource=”svntask.properties”/>
This is required as it defines the svn task. the svntask.properties can be found in svnant.jar. This defines the task svn to map to org.tigris.subversion.svnant.SvnTask.
It is equivalent as to writing
<taskdef name=”svn” classname=”org.tigris.subversion.svnant.SvnTask” />
To checkout the xml is
<svn javahl=”false” username=”${svnant.repository.user}” password=”${svnant.repository.passwd}”>
<checkout url=”${svn.url}” destPath=”${svn.workdirectory}” />
</svn>
javahl defaults to true. So unless you have the native JNI interface it is better to install subversion and use javahl=”false”.
The various subversion commands which can be used in ant can be found insubclipse:Svn task
July 28th, 2007 at 4:12 am
[…] in Ant, Java at 4:11 am by deadmanwalking On a previous post Subversion, Ant and SVN task I talked about how to use the SVN ant task. However for this to work i had to install the svn […]
October 30th, 2007 at 1:54 pm
For some reason, username/password is not being sent via the task. This may have to do with me using 1.4.5 of SVN client, but I am not sure. Have you had this same issue?
November 6th, 2007 at 3:25 am
Hi Ken,
No i have not had the issue. I have used the ant task to commit,read as well as copy. Could you please tell what is the exact error that you are facing?
December 20th, 2007 at 4:17 pm
I can get Ant to do checkouts and updates with the SVN command, but can’t get it to run the “info” command. My build environment is Windows XP, and I followed your installation instructions.
When I try to run the “svn info” command, this is the error message I get:
“svn doesn’t support the nested “info” element.” Yet according to the documentation, there is an svn info command.
I’m trying to get the SVN revision number in my Ant script so that I can use it in naming directories and other purposes.
December 31st, 2007 at 1:41 am
I had the same problem with “svn doesn’t support the nested “info” element.”
The fix for me was to use svnant-1.1.0-RC2 rather than svnant-1.0.0
I’m able to get the revision number now.
July 15th, 2008 at 8:19 pm
I was tired of SvnAnt being outdated and difficult to work with. So, I just started a nice simple project for ant + svn.
http://code.google.com/p/svntask/
October 22nd, 2010 at 6:44 pm
[…] […]
May 4th, 2012 at 7:05 pm
amzing..thanks a lot for nice post