Tags

,

first thing first… make sure you have Ant (http://ant.apache.org/) installed. Depending on the Subversion you are using, you have to download the specific version of svnAnt from http://subclipse.tigris.org/svnant.html. Download the zip file and unzip it in your local drive. Say you unzipped on C:\svnAnt, under that folder you would see the documents related to all the task available.

The important thing is, you have to make sure svnAnt related libraries are available when you execute ant and using svnAnt related stuffs. Personally I don’t like jar all over the places so I put the needed jars under ANT_HOME/lib. So copy svnant.jar, svnClientAdapter.jar and svnjavahl.jar and put them under ANT_HOME/lib.

You are set. Start writing your ant script with the following within the project element

<!–  Set-Up of svnAnt classpath  –>
<path id=”svnant.classpath”>
<fileset dir=”${lib.dir}”>
<include name=”**/*.jar” />
</fileset>
</path>

<!–   Loading of SVN task  –>
<typedef resource=”org/tigris/subversion/svnant/svnantlib.xml” classpathref=”svnant.classpath” />

Example of a build script

<?xml version=”1.0″?>
<!– build file used to checkin or commit svnant’s sources –>
<project name=”testsvnant” basedir=”.” default=”clean”>

<!–  all properties are in build.properties –>
<property file=”build.properties” />

<!–  Set-Up of svnAnt classpath  –>
<path id=”svnant.classpath”>
<fileset dir=”${lib.dir}”>
<include name=”**/*.jar” />
</fileset>
</path>

<!–   Loading of SVN task  –>
<typedef resource=”org/tigris/subversion/svnant/svnantlib.xml” classpathref=”svnant.classpath” />

<!–  removes the folder source_latest and all of it’s content –>
<!–  this will remove the latest of the View from where you are running this script –>
<target name=”clean”>
<delete dir=”source_latest”/>
</target>

<target name=”getLatest”>
<svn username=”${svn.username}” password=”${svn.password}”>
<checkout url=”${svn.source.url}” revision=”HEAD” destPath=”source_latest” />
</svn>
</target>

<target name=”updateLocal”>
<svn username=”${svn.username}” password=”${svn.password}”>
<checkout url=”${svn.source.url}” revision=”HEAD” destPath=”source_latest” />
</svn>
</target>

</project>

and your build.properties would look something like

svnant.version=1.2.1

# —————————————————————————–
# all jars needed
# —————————————————————————–
lib.dir=D:/apacheANT/lib

# —————————————————————————–
# SVN connection detail
# —————————————————————————–
svn.view.url=http://blah.svnserver.net/svn/repos/view/trunk
svn.username=btooka
svn.password=somegum

Advertisements