2007-08-10

Ant: the subant tag

In SVN I have this hierarchy:

trunk/ --+
|
|
|
+ subProjectA/ -+
| |
| +- build.xml
|
|
+ subProjectB/ -+
|
+- build.xml


under trunk I've added a build.xml file and using the Ant 1.6 tutorial I've added this build.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<project default="dist" name="My Project">
<macrodef name="iterate">
<attribute name="target"/>
<sequential>
<subant target="@{target}">
<fileset dir="." includes="*/build.xml"/>
</subant>
</sequential>
</macrodef>

<target name="dist">
<iterate target="dist"/>
</target>

<target name="compile">
<iterate target="compile"/>
</target>

<target name="clean">
<iterate target="clean"/>
</target>
</project>


This presumes all sub projects have a compile, clean, and dist target. I may add a test target as well.