Ant and Subversion: Building Model-Glue

A few people have asked how I create the Model-Glue .zip files. I'll be covering this in increased detail in a talk at CFUnited, but what follows is a quick overview.

[Read more on Joe Rinehart's blog]

First, I install SVN onto my workstation. You can get it at Just having the TortoiseSVN client isn't enough - you need to be able to run command-line SVN commands.

Second, I install Apache Ant. You can get it at There's good docs there on how to set it up, but it's important to remember to add its \bin dir to your path (I use c:\ant\bin).

Last, I write an Ant script that does a checkout of a given revision to a temp directory, cleans up the files, and then zips up the whole thing. The script for building a Model-Glue .zip follows, with comments:

<!-- Note that the basedir is explicitly set! -->
<project name="MyProject" default="build" basedir="c:/inetpub/wwwroot/modelgluebuilds">
<!-- SVN settings -->
<property name="svn.revision" value="68"/>
<property name="svn.username" value="svnUsername"/>
<property name="svn.password" value="svnPassword"/>
<property name="svn.projecturl" value="svn://url/to/your/repo"/>

<!-- A dir for temp files -->
<property name="build.temp" value="Temp" />
<!-- A dir for clean files -->
<property name="build.clean" value="Clean" />
<!-- Filename of the .zip to create -->
<property name="build.filename" value="myProject_{svn.revision}.zip" />

<!-- Create the temp and clean dirs if necessary -->
<target name="createArchiveDir">
<mkdir dir="${build.temp}"/>
<mkdir dir="${build.clean}"/>

<target name="build" depends="createArchiveDir">
<!--- Check out the code into the temp dir -->
<exec executable="svn">
<arg line="co ${svn.projecturl} ${build.temp} -r ${svn.revision} --username ${svn.username} --password ${svn.password}"/>

<!-- Remove any Eclipse .project files that someone may have committed -->
<delete file="${build.temp}/.project" />

<!--- Do any changes to any files here -->

<!-- Move it all to the clean dir -->            
<copy todir="${build.clean}">
<fileset dir="${build.temp}">
<exclude name="**/*.svn"/>

<!-- Zip up the clean dir and copy the zip to the basedir -->
<zip destfile="${build.clean}/${build.filename}" basedir="${build.clean}" />
<copy todir="">
<fileset dir="${build.clean}" includes="${build.filename}" />

<!-- Remove temp and clean dirs -->
<delete dir="${build.temp}" />
<delete dir="${build.clean}" />

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
© 2018 Joe Rinehart
BlogCFC was created by Raymond Camden. This blog is running version