Simple Integration of Ant and Subversion

Last week I decided it was time to start looking at integrating the check-out of code from Subversion as a part of my build process for the various projects I work on. Turns out, it’s pretty easy.

Download the CLI Subversion client and install it. You may need to reboot afterwards (I rebooted my machine in the process of getting this to work, so it’s possible that the path variable changed then.)

Below are a few snips from one of my build.xml files which pull the code out of Subversion using the CLI client. It probably won’t be formatted correctly (something seems to be tripping up the code tag), but I’ll check it out later.

<property name="root.dir" value="${basedir}"/>

<property name="root.src" value="c:\wwwroot"/>
<property name="" value="c:\wwwroot"/>
<property name="root.buildpath" value="c:\Builds"/>
<property name="root.backuppath" value="c:\Backups\Code" />
<property name="root.testingpath" value="\servername\path"/>

<property name="" value="ThisProject" />
<property name="" value="${}${}"/>
<property name="" value="${root.buildpath}${}"/>
<property name="project.backup.root" value="${root.backup}${}" />
<property name="project.testing.root" value="${root.testing}${}"/>

<property name="svn.rooturl" value="svn://svnurlhere/"/>
<property name="svn.username" value="svnusername"/>
<property name="svn.password" value="svnpassword"/>
<property name="svn.projecturl" value="${svn.rooturl}${}/trunk/"/>
<property name="svn.revision" value="HEAD"/>

<target name="cleanBuild" description="Cleans the build directory">
<delete dir="${}" />

<target name="createBuildDir" description="Creates the build directory">
<mkdir dir="${}" />

<target name="makeBuild" description="Pulls code from Subversion into the build directory" depends="cleanBuild,createBuildDir,checkoutBuild">


<target name="checkoutBuild" description="Pulls code from Subversion into the build directory">
<exec executable="svn">
<arg line="co ${svn.projecturl} ${} -r ${svn.revision} --username ${svn.username} --password ${svn.password}"/>

This entry was posted in Culture, Languages, Tips, Hacks, & Tricks, Tools and tagged , , , , , . Bookmark the permalink.

8 Responses to "Simple Integration of Ant and Subversion"

Leave a reply