Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to checkout from SVN with an ANT task?

Tags:

svn

ant

I'm interested in any way that I can create an Ant task to checkout files from SubVersion. I "just" want to do the checkout from the command line. I've been using Eclipse with Ant and SubVersion for a while now, but my Ant and SubVersion knowledge is somewhat lacking as I relied on Eclipse to wire it all together.

I've been looking at SvnAnt as one solution, which is part of Subclipse from Tigris at http://subclipse.tigris.org/svnant/svn.html. It may work fine, but all I get are NoClassDefFoundErrors. To the more experienced this probably looks like a simple Ant configuration problem, but I don't know about that. I copied the svnant.jar and svnclientadapter.jar into my Ant lib directory. Then I tried to run the following:

<?xml version="1.0"?>

<project name="blah"> 

 <property environment="env"/>

 <path id="svnant.classpath">
  <pathelement location="${env.ANT_HOME}/lib"/>
  <fileset dir="${env.ANT_HOME}/lib/">
   <include name="svnant.jar"/>
  </fileset>
 </path>

 <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" /> 

 <target name="checkout">
  <svn username="abc" password="123">
   <checkout url="svn://blah/blah/trunk" destPath="workingcopy"/>
  </svn>
 </target>

</project>

To which I get the following response:

build.xml:17: java.lang.NoClassDefFoundError: org/tigris/subversion/javahl/SVNClientInterface

I am running SVN 1.7 and SvnAnt 1.3 on Windows XP 32-bit.

Thanks for any pointers!

like image 475
Josh Avatar asked Mar 08 '10 11:03

Josh


People also ask

How do I checkout from svn in terminal?

Open the SVN server, right-click on the repository and select the copy URL to clipboard (for the VIsualSVN server) and paste it on the command line. User credentials will be the same as what we set at the time of user creation. After every successful checkout operation, the output will print a revision number.

How do you run an ant task?

To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.

What is checkout in Subversion?

Advertisements. Subversion provides the checkout command to check out a working copy from a repository. Below command will create a new directory in the current working directory with the name project_repo.


2 Answers

If you don't get SvnAnt working, you can always use exec:

<exec executable="/usr/local/bin/svn">
    <arg value="co" />
    <arg value="svn://repository/url" />
    <arg value="/destination/directory" />
</exec>
like image 98
JW. Avatar answered Sep 30 '22 12:09

JW.


From that error it seems you probably need JavaHL jar on your classpath as well (JavaHL is Java language bindings for the Subversion API). You a

This URL might help: http://subclipse.tigris.org/wiki/JavaHL

Otherwise you can use use Ant to run a native command (but that would make it OS-dependant of course).

like image 30
Wilhelm Kleu Avatar answered Sep 30 '22 13:09

Wilhelm Kleu