Edward Dale
Edward Dale

Reputation: 30133

Calling multiple ant targets from ant

From my main build file, I would like to call the same target in multiple other build files. My current solution is to call them separately, like so:

<ant antfile="${lib_src_dir}/mylib1/build.xml" target="build" inheritAll="false"/>
<ant antfile="${lib_src_dir}/mylib2/build.xml" target="build" inheritAll="false"/>

I would like my build file to just call the build target on the build files in all of the subdirectories of ${lib_src_dir}. I know I could use the foreach tasks from ant-contrib, but I'd like to stay away from an external library if possible.

I've tried the following, which didn't work:

<ant antfile="${lib_src_dir}/*/build.xml" target="build" inheritAll="false"/>

Upvotes: 2

Views: 2172

Answers (2)

Edward Dale
Edward Dale

Reputation: 30133

Here's what I ended up with, using the subant task:

<subant target="clean">
    <fileset dir="${lib_src_dir}" includes="*/build.xml" />
</subant>

Upvotes: 1

ChrisH
ChrisH

Reputation: 4826

You want the subant task.

Upvotes: 2

Related Questions