tags:

views:

119

answers:

4
+2  Q: 

Ant meta build

In ant, is there a way to combine multiple ant builds to deploy to a meta-project. For example I have

workspace/project1/build.xml
workspace/project2/build.xml

and I want to make

workspace/build.xml

that will run specific targets in project1 and project2.

A: 

The "antcall" task is probably what you need. It allows you to invoke specific targets in other ant files. You can optionally transfer all currently defined properties and references to the invoked target.

Note that this isn't to be confused with the "ant" target, which is for invoking targets in the current ant file.

skaffman
+1  A: 

I think that's backwards, isn't it? "ant" allows you to specify another build file, while "antcall" is just for calling a particular target.

jjb
+3  A: 

The ant task does this. In addition there is also an import task which can allow you to make the sub ant files as part of the larger project file. But realistically you would probably only do that if the sub-project's ant file was built for that in the first place.

Yishai
+3  A: 

I would recommend the subant task instead of either ant or antcall. For the example above, use the following in workspace/build.xml:

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

Refine the fileset as needed to pick up all the project subdirectories (use **/build.xml to pick up all subdirectories that contain a build.xml file).

Jason Day