ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Colm Smyth" <>
Subject Tiny patch to enable Recursion in Ant
Date Sun, 11 May 2008 22:51:25 GMT

I wanted to be able to easily write recursive Ant build files, so I
developed a macro and a small patch to Ant. I'd like the advice of the
dev list as to if and how I should submit this patch for inclusion in

The patch (roughly 30 extra lines of code across 6 files) adds two new
*dynamic* properties to Ant:
 1) - the default target of the current project
 2) - a comma-separated list of the actual targets
that were invoked on the current project

These properties are updated automatically, similar to ant.file or

The "recurse" macro uses the antcontrib:for task to iterate over
multiple targets (the antcontrib jar required the "for" task to be
added to its properties). The macro can accept an explicit list of
targets, but I also wanted to be able to recurse on the targets that
were actually invoked.

Here's how you would use it:

 <!-- define the "recurse" macro -->
 <typedef file="recurse.xml"/>

 <!-- "subdirs" is the ordered list of sub-folders that "recurse" uses -->
 <filelist dir="." id="subdirs" files="x1,x2"/>

 <!-- invokes the macro on the current target(s), which may be the
ones specified or the default target -->

 <!-- invoke the macro on the specified targets -->
 <recurse targets="this,that,other"/>

My Ant experience is limited, so I may have overlooked an existing way
to achieve this, but reading and searching suggests that others are
still missing recursion in Ant. I look forward to your advice!

 All the best,

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

View raw message