Subversion, Ant and SVN task

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


8 responses to “Subversion, Ant and SVN task

Leave a reply to Ken George Cancel reply