Use Ant to Maintain Custom Framework Builds

2008 May 18
by Paul Marcotte
I'm pretty new to Ant, so I'm thankful that a lot of other developers have examples and sample build files that I can use as a guide to learning Ant. After writing a few small build files, I wanted to tackle something a little more ambitious. I like to keep all the frameworks that I use up to date from their respective repositories, and, when deploying a new site or project, I will typically include the framework dependencies as a minimal include at the project root. This requires a bit of work, exporting and stripping out documentation, examples and tests from my local checkout of the framework files. As a learning objective, I decided to write an ant build file to maintain my own "nightly build" of each framework customized to carry only the core files.I'm going to assume that anyone interested in this post will already have all the necessary dependencies. Which are: Ant
A CVS command line client
SVNAnt On OS X, the simplest way to get a CVS client is to install the Apple Developer Tools. There are plenty of guides available to install and setup ant and svnant, so I won't re-hash them here. For the first cut of this build file, I chose to setup tasks to export ModelGlue, MachII, Coldspring, Transfer and Coldbox. The process is to export the core files to a temp directory, then copy the files to a location where I will point the Coldfusion Administrator to create mappings to each framework. Here are the properties and build files respectively.
# ant lib path and svn ant jars

#local props



# MachII




<?xml version="1.0"?>
<project name="svn-test" basedir="." default="exportFrameworks">

<!-- all properties are in -->
<property file="" />

<!-- path to the svnant libraries. Usually they will be located in ANT_HOME/lib -->
<path id="project.classpath">
<pathelement location="${svnjavahl.jar}" />
<pathelement location="${svnant.jar}" />
<pathelement location="${svnClientAdapter.jar}" />

<!-- load the svn task -->
<taskdef resource="" classpathref="project.classpath"/>

<!-- model glue export -->
<target name="exportModelGlue">
<svn >
<export srcUrl="${model-glue.svn}" revision="HEAD" destPath="${tempdir}/ModelGlue" />

<!-- mach-ii export -->
<target name="exportMachII">
<svn >
<export srcUrl="${mach-ii.svn}" revision="HEAD" destPath="${tempdir}/MachII" />

<!-- transfer export -->
<target name="exportTransfer">
<svn >
<export srcUrl="${transfer.svn}" revision="HEAD" destPath="${tempdir}/transfer" />

<!-- coldbox export -->
<target name="exportColdbox">
<svn username="${coldbox.username}" password="${coldbox.password}">
<export srcUrl="${coldbox.svn}" revision="HEAD" destPath="${tempdir}/coldbox/system" />

<!-- coldspring export -->
<target name="exportColdSpring">
<cvspass cvsroot="${coldspring.cvs}${coldspring.repo}"
command="export -DNOW ${coldspring.module}"


<!-- list of export tasks -->
<target name="export" depends="exportModelGlue,exportMachII,exportColdbox,exportTransfer,exportColdSpring" />

<!-- copy task - -->
<target name="copy">
<mkdir dir="${targetdir}" />
<copy todir="${targetdir}">
<fileset dir="${tempdir}">
<exclude name="**/coldspring/docs/**" />
<exclude name="**/coldspring//examples/**" />
<exclude name="**/coldspring//tests/**" />
<exclude name="**/coldspring//unitTests/**" />

<!-- clean task - remove temp dir -->
<target name="clean">
<delete dir="${tempdir}"/>

<!-- default task -->
<target name="exportFrameworks" depends="clean,export,copy">
<echo message="frameworks updated" />

If you are like me and prefer to keep the frameworks that you use up to date and lean, I hope you find this useful.