ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shackelford, John-Mason" <>
Subject refactoring a large project
Date Sat, 20 Jul 2002 18:23:40 GMT
Here I am sitting in the office on a Saturday afternoon facing a much needed
refactoring of a large ant script: 4456 lines spreada across 22 entities and
one build.xml. We use this design rather than nested build.xml files because
developers need to maintain control over various parts of the process and
execute the targets explicitly. The default target is just a lengthy help

The particular problem I am faced with today is that the build file uses
antcall innappropriately which and causes targets to run multiple times. The
reason antcall was used in the first place is that the script builds two
different versions of the product depending on a value set in a property
file and an antcall handles this:

<target "build.all">
	<antcall target="build.all.${build.version}"/>

Realizing that using antcall completely uncuts ant's ability to keep track
of dependencies, I began refactoring by having an init target:

<target name="init">
	<!--                                -->
	<!--    set flags for build version -->
	<!--                                -->
	<condition property="build.v32">
		<equals arg1="${}" arg2="v32"/>
	<condition property="build.v40">
		<equals arg1="${}" arg2="v40"/>

and then making a few other changes:

<target name="build.all" depends="init,build.all.v32,build.all.v40"/>
<target name=build.all.v32" if="build.32" depends="init">
<target name=build.all.v40" if="build.40" depends="init">

Then I ran into another problem. Since dependencies are always executed, all
the dependencies for build.all.v32 and build.all.v40 are always executed so
all of those targets now need to include my if="build.v32" or if="build.v40"
attribute. I realize all of the sudden that I have a monster on my hands:
what happends when it is time to add a new version???

So I am thinking I should make the two versions entirely seperate, but how
am I to accomplish this and still have:

#1 the ability to switch versions purely on the basis of a property file. 
#2 top level control of all the targets in the scripts (i.e. using <ant> is
probably not going to work for me).


I have read the docs, Ant in Anger, Tilly & Burke's book, (and today I
bought Hatcher & Loughran's--which am really looking forward to), and
anything else I could find on the web. But what I really need now is a pair
:s Anyone interested in walking through this with me?

John-Mason Shackelford

Software Developer
NCS Pearson - Measurement Services
2510 North Dodge St.
Iowa City, IA 52245

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message