ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: refactoring a large project
Date Sat, 20 Jul 2002 19:05:25 GMT
Was about to send a solution, before I realize it didn't solve anything :-(

What you really wanted would be what was said about one of the Ant2
proposal, where you could have done

<target name="build.all.v32"
  <depends target="step1" />
  <depends target="step2" />

So only init is executed before you have a chance to bail out when build.v32
is not set. Otherwise, you continue executing your other dependencies. I
would love to be able to say the above. It would reduce the spaghetti Ant
code one has to write now with zillions of targets with if/unless

That said, I don't get why you say you have targets running several times.
You have your <antcall> that call the version-specific build.all.vXX at the
top level, so you're fine! You must have other <antcall>'s elsewhere!?!?

I'm so disappointed Ant2 was hijacked, and we're going with evolution rather
than revolution. Ant2 was the perfect opportunity to 'spec out' what should
be the behavior of the next Ant (in terms of property handling passing down
to sub-project, class loaders, templating, etc...), and there was so much
great stuff in Mutant and Myrmidon. Now we're just hacking on top of
ProjectHelper, which as useful as it is for Ant1, is just not clean IMHO.

When I pushed for using Ant is many other projects within my company, and
was saying Ant was the way to go, and was the way of the future, a *very
good* developer told me 'yeah, no now, until the next great thing comes
along'. I retorted the next great thing was Ant2, but now I doubt...

Sorry I didn't help you much there. --DD

-----Original Message-----
From: Shackelford, John-Mason []
Sent: Saturday, July 20, 2002 1:24 PM
To: ''
Subject: refactoring a large project

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: <>

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

View raw message