Tuesday, June 17, 2008

SVNAnt on Vista Gotcha

I thought I would quickly blog this issue for anyone else struggling to get SvnAnt working on Windows Vista. I have been trying to streamline my deployments using Ant running within Eclipse and as an important part of that task I wanted to integrate my source control. I attempted to use the SvnAnt task to perform operations (such as export, commit, etc) on my Subversion repository.

However I've just spent over an hour trouble-shooting a problem with this task. The cliff notes version of the resolution is this simple realisation:

You can not use the 'command line' (as opposed to JNI) interface on Vista. Read on for the background.

SvnAnt allows you to specify two ways of connecting to SVN. Using the command line interface (effectively executing the command line binary) or using a native library (javahl) through JNI.

My initial approach was to try to use the command line. the subversion binary was already on my path and I knew it worked OK. Although the JNI implementation is reportedly more performant I tried to attack the simplest approach first.

However while experimenting I kept getting the simple error:

Cannot use javahl nor command line svn client

Documentation on the web (provided by my friend and yours, Google) provided me many references to this problem. It seems that with respect to the command line client interface, the PATH environmental variable must include the subversion binary directory. This had me scratching my head, since the subversion binaries were on my path. I began investigating whether the path variable was not available or different, either because I was running Ant via Eclipse run as administrator, or because Eclipse was spawning Ant in its own JRE.

After a lot of investigation, I discovered in my case this was a complete red-herring. On Vista, the subversion executable svn.exe requires an environmental variable SystemDrive that the SvnAnt task purposefully strips as described in this post by John E. Leon Guerrero. So the bottom line is that it is not possible to use the command line interface into Subversion from SvnAnt on Microsoft Vista.

John goes on to describe how to use the DLL distributed with Subclipse for the JNI interface by adding it to the path. This worked immediately for me.

To restate: You must use the JNI/Javahl interface into Subversion if you intend to use SvnAnt on Microsoft Vista.

As a side note, when debugging a possible Ant environment issue, either within Eclipse or from the command line, consider passing the ‘-diagnostics’ argument, which produces a nice output of the environment Ant is running in.

Hope this helps someone!

No comments:

Post a Comment