Cloudmark Desktop Banner

Installing SVNAnt into Eclipse

On my road of exploration for ANT, and the end goal of using it for deployment, I have had to tackle how to get files out of SVN ready for moving to a server. This means getting ANT to run the equivalent of an svn export from the command line.

This is possible using the command line client through ANT thus:

<exec executable="svn">
<arg line="co ${svn.projecturl} ${build.temp} -r ${svn.revision} --username ${svn.username} --password ${svn.password}"/>
</exec>

However there is a nicer way that doesn't involve installing the SVN command line client. Enter SvnAnt.

To install it download the latest stable build, I have used the svnant-1.0.0.zip. Take the jar files

  • svnant.jar
  • svnClientAdapter.jar
  • svnjavahl.jar
And place them somewhere sensible. I used my workspace directory c:\development\development or perhaps the \eclipse\plugins\org.apache.ant_1.6.5\lib ANT lib directory inside my eclipse folder.

Once you have placed your jar files, you need to get Eclipse to load them at runtime. I read somewhere that using the ANT folder above and a simple restart would have Eclipse pick them up, but that didnt work for me.

  1. Open Eclipse
  2. Window > Preferences
  3. Ant > Runtime
  4. Ant Home Entries (Default)
  5. Click Add External JARs
  6. Navigate to c:\development\workspace or wherever you unzipped the jar files
  7. Select the 3 .jar files
  8. Open > Apply > OK
  9. Restart Eclipse

You should now be able to run the svn tasks. Here is an example to update a local working copy.

<!-- update working copy to make sure -->
<echo message="updating working copy at ${svn.wc}" />

<svn username="username" password="password">
         
   <update dir="c:\development\testrepo\"/>

</svn>

Comments
Dave's Gravatar ¿How i can create an ant tag that moves the not commited files to an external ubication?
# Posted By Dave | 24/08/07 07:00
dickbob's Gravatar Like you I'm new to ANT and have just found your ANT series. Very interesting!

Following this posting I get the error "Cannot use javahl nor command line svn client".

Any thoughts what I've done wrong?
# Posted By dickbob | 27/09/07 00:43
Duncan's Gravatar the javahl dll file needs to be on your PATH to be able to load. svntask uses a System.loadLibrary() to load this dll, so modify your PATH variable and add the dir of where that dll is at. If you get subclipse for subversion then you can find javahl in the plugins dir, i think.

You can check what your path is by doing:
System.out.println(System.getProperty("java.library.path"));
after you change your path, you may need to reboot because windows is stupid.
# Posted By Duncan | 27/09/07 08:32
dickbob's Gravatar I don't seem to have javahl.dll anywhere on my computer. I can find a svnjavahl.jar file. Do you mean the DOS PATH?
# Posted By dickbob | 27/09/07 21:06
dickbob's Gravatar To answer my own question, it seems like if you install Subversion 1.3.2 locally it will provide all the right files in the install bin directory and update the Windows PATH to point there.
# Posted By dickbob | 27/09/07 23:27
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.