Using SVNANT in your ANT build files with Hudson

Tuesday, September 22, 2009

This is a quick post about a gotcha I ran into today with Hudson and SVNANT.

The Ant Target

<property name="libdir" location="lib" />
<path id="classpath">
        <fileset dir="${libdir}" includes="*.jar" excludes="svnant.jar" />
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="classpath" />
...bunch of stuff
<svn  username="mesher" password="mesher">
        <update dir="${src}${path}"  />
...some other stuff

The Problem

I ran the Hudson build, and I got the dreaded "[echo] Error updating dev: Cannot use javahl nor command line svn client"


The first thing I did was throw this into my build file, right above the svn task:


This quickly showed me the problem: the ANT_HOME directory had svnant jars in there, and so the svn task was using those old jars and NOT the jars I had specified on my classpath.

The Solution

I did two things:

  1. Remove those jars from the lib dir of my ant install. I do not remember how they got there, but they should not have been there and were thus evicted
  2. Started using svnkit instead of javahl. Thus, the svn task now looks like this:
<svn  username="mesher" password="mesher" svnkit="true" javahl="false">
        <update dir="${src}${path}"  />


Bottom Line

Don’t let friends put svnant jars in your ant_home lib directory


Anonymous said...

a-hole - if you are going to comment on someone else's blog be constructive. Based on one sentence on Barney B's blog you are clearly an ass.

billy said...

@Anonymous, I think you might have misinterpretted Marc's comment, which was totally in jest. I got a laugh out of it and I'm sure Barney did, too.


Marc Esher said...

A, bill is right... it was most assuredly in jest.

Also, A, I'm sorry you were born with such a generic name. It must be hard living with that kind of pain, and for that you have my sympathies. :-)

bill, A is right... I can be an a-hole.

Now... does anyone have anything to say about SVNAnt and Hudson?

Jamie Krug said...

Hey Marc, thanks for another helpful post! I just came across this while Google-ing "svnant cfeclipse" :)

I've searched a few other options too, and hope you don't mind asking a slightly related total n00b question... I'm trying to use SVNAnt for the first time, and simply want to add a few svn export tasks to my ANT build. I can't seem to find any clear indication on how to best "install" SVNAnt.

Tips? Do I just need to manually download the correct zip and locate the svnant.jar in a class path? Do I always need that "typedef" line in each build file, or can I tell Eclipse/Ant to somehow always be aware (maybe by locating jar in existing lib for ant??)?

My takeaway from your post here is to always use svnkit="true" and javahl="false" -- yes?

Sorry for the lengthy comment and list o' questions! Maybe we can take this "offline" if this is the wrong forum, but I can't seem to find a clear answer out there. Thanks!

Marc Esher said...

Hey Jamie,

Until recently, I wouldn't have known enough to suggest svnkit over javahl. But my recent experience is that it's so much easier to use svnkit. The only thing I've found so far, which isn't a big deal at all, is that svn updates require credentials with svnkit whereas with javahl they didn't. So... no biggie.

as for the typedef, yes, you always need that in your build file. As for the classpath, you can:

1) drop the svn jars in your ant-home lib directory and then you won't need to specify the classpath in your ant file

2) specify the classpath and typedef in every build file

3) create a build file that has the classpath and typedef and then "import" that buildfile in your other ant files that want to use svnant.

let me know how you make out.

Jamie Krug said...

Thanks, Marc! Here's what I did.

Marc Esher said...


Hays said...

Mmm... looks like this is out of date. :(

[svn] Deprecated attribute 'username'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
[svn] Deprecated attribute 'password'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
[svn] Deprecated attribute 'svnkit'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
[svn] Missing 'javahl' dependencies on the classpath !
[svn] failed.