ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 44980] New: Recursion in Ant
Date Mon, 12 May 2008 23:55:07 GMT

           Summary: Recursion in Ant
           Product: Ant
           Version: 1.7.0
          Platform: PC
        OS/Version: Windows Vista
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core

Created an attachment (id=21953)
 --> (
Ant Recursion Patch

Ant has some support for recursing a target down a build hierarchy in the form
of the following:
- fileset can specify a list of directories or build files
- antcontrib:for can do iteration

However each target has to handle recursion itself.

I have developed a 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 (btw, the currnet antcontrib jar is missing the "for" task in
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 falls back to the default target -->

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

I've attached the patch. The "recurse" macro is trivial using the new
<?xml version="1.0"?>
<antlib xmlns:antcontrib="antlib:net.sf.antcontrib">
    <macrodef name="recurse">
        <attribute name="targets" default="${}"/>
            <condition property="recurseTargets" value="${}"
              <equals arg1="@{targets}" arg2="" />
            <antcontrib:for list="${recurseTargets}" param="target">
                    <subant target="@{target}">
                        <filelist refid="subdirs"/>

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

View raw message