From 600708566b39118a662d2b8f3d7a4b2356d9a319 Mon Sep 17 00:00:00 2001 From: Jan Materne Date: Tue, 7 Sep 2004 05:59:37 +0000 Subject: [PATCH] Integrate complex example into mergefile. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276824 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/SubAnt.xml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/proposal/xdocs/src/org/apache/tools/ant/taskdefs/SubAnt.xml b/proposal/xdocs/src/org/apache/tools/ant/taskdefs/SubAnt.xml index 6a268f0af..981eaf818 100644 --- a/proposal/xdocs/src/org/apache/tools/ant/taskdefs/SubAnt.xml +++ b/proposal/xdocs/src/org/apache/tools/ant/taskdefs/SubAnt.xml @@ -67,5 +67,63 @@ this snippet will execute the compile target of /opt/project/build1.xml, setting the basedir to projects1, projects2, projects3

+

Now a little more complex - but useful - scenario. Assume that we have + a directory structure like this:

+
+        root
+          |  common.xml
+          |  build.xml
+          |
+          +-- modules
+                +-- modA
+                |     +-- src
+                +-- modB
+                      +-- src
+
+        common.xml:
+ <project> + <property name="src.dir" value="src"/> + <property name="build.dir" value="build"/> + <property name="classes.dir" value="${build.dir}/classes"/> + + <target name="compile"> + <mkdir dir="${classes.dir}"/> + <javac srcdir="${src.dir}" destdir="${classes.dir}"/> + </target> + + <!-- more targets --> + </project> + + build.xml:
+ <project> + + <macrodef name="iterate"> + <attribute name="target"/> + <sequential> + <subant target="@{target}"> + <fileset dir="modules" includes="*/build.xml"/> + </subant> + </sequential> + </macrodef> + + + <target name="compile"> + <iterate target="compile"/> + </target> + + <!-- more targets --> + </project> + + modules/modA/build.xml:
+ <project name="modA"> + <import file="../../common.xml"/> + </project> +
+ +

This results in very small buildfiles in the modules, maintainable + buildfile (common.xml) and a clear project structure. Additionally + the root buildfile is capable to run the whole build over all + modules. +

\ No newline at end of file