ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Berry <christopher.be...@etrade.com>
Subject RE: looping (RE: Foreach task)
Date Mon, 11 Jun 2001 20:18:50 GMT
Greetings,

As the one who (innocently) began this debate, I will chime in. Although I
suspect that this argument has become religious, and as such, neither side
is listening to the other anymore...

In my current build, I have used <foreach> three times, and I do not see an
alternate approach. 

1) Loop over all TAR.GZ files in a directory and unpack them -- using a
generic unpack-GZfile-build.xml which takes the base filename as a supplied
property. I do not think one could do this generically w/ the current Ant
Tasks, or at least I couldn't figure it out.

2) Loop over every subdir in a directory and call it's build.xml file (if it
exists). Our Apps build independent of each other -- calling into a shared
common-build.xml. But we must also provide a generic "full build" procedure,
which can build an unknown set of Apps. Of course, one could require that
full-build.xml be edited whenever Apps were added or deleted, but wouldn't
that be error-prone?? To me this would be similar to explicitly adding JARs
to a Classpath, rather than just implicitly adding all JARs in the /lib
directory. One way requires no future intervention, the other constantly
bites you...

3) Loop over every file in a particular directory that matches a specific
pattern, and pass it off to another Task. In this case, a home-grown Task
which pulls a Version number from the filename, determines the maximum
Version number in use, and writes it to a property for use in a subsequent
Ant Task.

Obviously I could have written a home-grown Task for each of these foreach
instances. But where is the elegance in that?? Isn't "Don't Repeat Yourself"
one of the cardinal rules of development. 

Cheers,
-- Chris
 

Mime
View raw message