ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: Task from a task?
Date Mon, 30 Apr 2001 21:49:53 GMT
--- Jeffrey A Kenward <> wrote:
> What's the best way to invoke a task from another task?
> For instance, I'm trying to write a task to search for build files
> further down in the build tree and invoke the ANT task on it once it's
> found.

You could use the newly submitted (but not committed) <foreach> task (I
picked up Chris Greenlee's updated version) -- see the ant-dev mail
archives at message:

It's designed to do <antcall>'s, which means running a target in the
current build-file, but that target could do an <ant>. For example:

  <target name="recurse">
    <taskdef name="foreach"
    <foreach target="runAnt">
      <param name="file">
        <fileset dir="." includes="**/build.xml"/>

  <target name="runAnt">
    <ant antfile="${file}"/>

This will run the default target in each build.xml file in every
subdirectory of the current directory. If you want to run a specific
target in the sub-project build-files, include the "target" attribute in
the <ant> task (include nested <property>'s if you want to override
property values in the sub-project build-files).

Note: You'll need to pick up the latest from CVS, as apparently
the <foreach> task hits a bug that was in the 1.3 version, which has since
been fixed in CVS.



Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

View raw message