2004-09-01 16:11:14 +00:00
2003-03-26 17:55:37 +00:00
< html >
< head >
< meta http-equiv = "Content-Language" content = "en-us" >
< title > Subant
Task< / title >
< / head >
< body bgcolor = "#ffffff" text = "#000000" link = "#525D76"
alink="#525D76" vlink="#525D76">
< table border = "0" width = "100%" cellspacing = "4" >
<!-- PAGE HEADER -->
< tr >
< td >
< table border = "0" width = "100%" > < tr >
< td valign = "bottom" >
< font size = "+3" face = "arial,helvetica,sanserif" > < strong > Subant
Task< / strong > < / font >
2003-12-12 10:14:26 +00:00
< br > < font face = "arial,helvetica,sanserif" > Calls a given target for all defined sub-builds.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td >
<!-- PROJECT LOGO -->
< a href = "http://ant.apache.org/" >
< img src = "../../images/ant_logo_large.gif" align = "right" alt = "Apache Ant" border = "0" / >
< / a >
< / td >
< / tr > < / table >
< / td >
< / tr >
<!-- START RIGHT SIDE MAIN BODY -->
< tr >
< td valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
<!-- Applying task/description -->
2003-03-26 17:55:37 +00:00
<!-- Start Description -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#525D76" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" >
< a name = "description" >
< strong > Description< / strong > < / a > < / font >
< / td > < / tr >
< tr > < td > < blockquote >
2003-05-14 09:57:38 +00:00
< p >
2003-12-12 10:14:26 +00:00
Calls a given target for all defined sub-builds.
This is an extension
of ant for bulk project execution.
2003-09-03 10:03:47 +00:00
2003-12-12 10:14:26 +00:00
< strong > This task must no be used outside of a
< code > target< / code > if it invokes the same build file it is
part of.< / strong >
2003-05-14 09:57:38 +00:00
< / p >
2003-05-21 07:27:26 +00:00
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
<!-- Subsection heading -->
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" >
< a name = "Use with directories" >
< strong > Use with directories< / strong > < / a > < / font >
< / td > < / tr >
<!-- Subsection body -->
< tr > < td >
< p >
subant can be used with directory sets to execute a build from different directories.
2 different options are offered :
< / p >
< ul >
< li >
to run the same build file < code > /somepath/otherpath/mybuild.xml< / code >
with different base directories, use the genericantfile attribute
< / li >
< li > if you want to run < code > directory1/mybuild.xml< / code > , < code > directory2/mybuild.xml< / code > , < code > ....< / code > ,
2003-12-12 10:14:26 +00:00
use the antfile attribute. The subant task does not set the base directory for you in this case, because you can specify it in each build file.
2003-05-21 07:27:26 +00:00
< / li >
< / ul >
< / td > < / tr >
< / table >
2003-05-14 09:57:38 +00:00
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Description -->
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
<!-- Start Attributes -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#525D76" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" >
< a name = "attributes" >
< strong > Parameters< / strong > < / a > < / font >
< / td > < / tr >
< tr > < td > < blockquote >
< table >
< tr >
< td bgcolor = "#cccccc" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > < b > Attribute< / b > < / font >
< / td >
< td bgcolor = "#cccccc" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > < b > Description< / b > < / font >
< / td >
< td bgcolor = "#cccccc" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > < b > Type< / b > < / font >
2003-05-14 09:57:38 +00:00
< / td >
< td bgcolor = "#cccccc" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > < b > Requirement< / b > < / font >
2003-03-26 17:55:37 +00:00
< / td >
< / tr >
2004-09-01 16:11:14 +00:00
<!-- Attribute Group -->
<!-- Attribute Group -->
2003-05-14 09:57:38 +00:00
<!-- Attribute -->
2003-03-26 17:55:37 +00:00
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > antfile< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-21 07:27:26 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Build file name, to use in conjunction with directories.< br / > Defaults to "build.xml".< br / > If < code > genericantfile< / code > is set, this attribute is ignored.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > String< / font >
< / td >
2003-05-22 07:27:51 +00:00
< td bgcolor = "#eeeeee" valign = "top" align = "left" rowspan = "9" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Optional< / font >
< / td >
2003-03-26 17:55:37 +00:00
< / tr >
<!-- Attribute -->
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > buildpath< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Set the buildpath to be used to find sub-projects.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Path< / font >
< / td >
< / tr >
<!-- Attribute -->
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > buildpathref< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Buildpath to use, by reference.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Reference< / font >
< / td >
< / tr >
<!-- Attribute -->
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > failonerror< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Sets whether to fail with a build exception on error, or go on.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > boolean< / font >
< / td >
< / tr >
<!-- Attribute -->
2003-05-21 07:27:26 +00:00
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > genericantfile< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Build file path, to use in conjunction with directories.< br / > Use < code > genericantfile< / code > , in order to run the same build file with different basedirs.< br / > If this attribute is set, < code > antfile< / code > is ignored.< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > File< / font >
< / td >
< / tr >
<!-- Attribute -->
2003-03-26 17:55:37 +00:00
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > inheritall< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Corresponds to < code > < ant> < / code > 's < code > inheritall< / code > attribute.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > boolean< / font >
< / td >
< / tr >
<!-- Attribute -->
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > inheritrefs< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Corresponds to < code > < ant> < / code > 's < code > inheritrefs< / code > attribute.< / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > boolean< / font >
< / td >
< / tr >
<!-- Attribute -->
2003-05-21 07:27:26 +00:00
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > output< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > Corresponds to < code > < ant> < / code > 's < code > output< / code > attribute.< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > String< / font >
< / td >
< / tr >
<!-- Attribute -->
2003-03-26 17:55:37 +00:00
< tr >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > target< / font >
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
2003-05-14 09:57:38 +00:00
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > < / font >
2003-03-26 17:55:37 +00:00
< / td >
< td bgcolor = "#eeeeee" valign = "top" align = "left" >
< font color = "#000000" size = "-1" face = "arial,helvetica,sanserif" > String< / font >
< / td >
< / tr >
2003-05-14 09:57:38 +00:00
2003-03-26 17:55:37 +00:00
< / table >
< / blockquote > < / td > < / tr >
< / table >
<!-- End Attributes -->
<!-- Start Elements -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#525D76" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" >
< a name = "elements" >
< strong > Parameters as nested elements< / strong > < / a > < / font >
< / td > < / tr >
< tr > < td > < blockquote >
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > dirset< / strong > (org.apache.tools.ant.types.DirSet)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Adds a directory set to the implicit build path. < p > < em > Note that the directories will be added to the build path in no particular order, so if order is significant, one should use a file list instead!< / em >
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > filelist< / strong > (org.apache.tools.ant.types.FileList)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Adds an ordered file list to the implicit build path. < p > < em > Note that contrary to file and directory sets, file lists can reference non-existent files or directories!< / em >
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > fileset< / strong > (org.apache.tools.ant.types.FileSet)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Adds a file set to the implicit build path. < p > < em > Note that the directories will be added to the build path in no particular order, so if order is significant, one should use a file list instead!< / em >
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > property< / strong > (org.apache.tools.ant.taskdefs.Property)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Corresponds to < code > < ant> < / code > 's nested < code > < property> < / code > element.
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-05-14 09:57:38 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > propertyset< / strong > (org.apache.tools.ant.types.PropertySet)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Corresponds to < code > < ant> < / code > 's nested < code > < propertyset> < / code > element.
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > buildpath< / strong > (org.apache.tools.ant.types.Path)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Creates a nested build path, and add it to the implicit build path.
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
<!-- Start Element -->
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#828DA6" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" size = "-1" >
< strong > buildpathelement< / strong > (org.apache.tools.ant.types.Path.PathElement)< / font >
< / td > < / tr >
< tr > < td > < blockquote >
Creates a nested < code > < buildpathelement> < / code > , and add it to the implicit build path.
2003-12-12 10:14:26 +00:00
<!-- Ignore -->
<!-- Ignore -->
2003-03-26 17:55:37 +00:00
< / blockquote > < / td > < / tr >
< / table >
<!-- End Element -->
< / blockquote > < / td > < / tr >
< / table >
<!-- End Elements -->
2003-05-14 09:57:38 +00:00
< table border = "0" cellspacing = "0" cellpadding = "2" width = "100%" >
< tr > < td > < / td > < / tr >
< tr > < td bgcolor = "#525D76" >
< font color = "#ffffff" face = "arial,helvetica.sanserif" >
< a name = "examples" >
2003-05-22 07:27:51 +00:00
< strong > Examples< / strong > < / a > < / font >
2003-05-14 09:57:38 +00:00
< / td > < / tr >
< tr > < td > < blockquote >
< pre >
< project name="subant" default="subant1">
< property name="build.dir" value="subant.build"/>
< target name="subant1">
2003-05-14 15:04:07 +00:00
< subant target="">
< property name="build.dir" value="subant1.build"/>
< property name="not.overloaded" value="not.overloaded"/>
< fileset dir="." includes="*/build.xml"/>
< /subant>
2003-05-14 09:57:38 +00:00
< /target>
< /project>
< / pre >
< p >
this snippet build file will run ant in each subdirectory of the project directory,
where a file called build.xml can be found.
2003-05-14 20:19:14 +00:00
The property build.dir will have the value subant1.build in the ant projects called by subant.
< / p >
< pre >
< subant target="">
< propertyset>
< propertyref prefix="toplevel"/>
< mapper type="glob" from="foo*" to="bar*"/>
< /propertyset>
< fileset dir="." includes="*/build.xml"/>
< /subant>
< / pre >
< p >
this snippet build file will run ant in each subdirectory of the project directory,
where a file called build.xml can be found.
All properties whose name starts with "foo" are passed, their names are changed to start with "bar" instead
2003-05-14 09:57:38 +00:00
< / p >
2003-05-22 07:27:51 +00:00
< pre >
< subant target="compile" genericantfile="/opt/project/build1.xml">
< dirset dir="." includes="projects*"/>
< /subant>
< / pre >
< p >
assuming the subdirs of the project dir are called projects1, projects2, projects3
this snippet will execute the compile target of /opt/project/build1.xml,
setting the basedir to projects1, projects2, projects3
< / p >
2003-05-14 09:57:38 +00:00
2004-09-01 16:11:14 +00:00
<!-- manually written -->
< p > Now a little more complex - but useful - scenario. Assume that we have
a directory structure like this:< / p >
< pre >
root
| common.xml
| build.xml
|
+-- modules
+-- modA
| +-- src
+-- modB
+-- src
< u > < b > common.xml:< / b > < / u > < br >
< 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>
< u > < b > build.xml:< / b > < / u > < br >
< 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>
< u > < b > modules/modA/build.xml:< / b > < / u > < br >
< project name="modA">
< import file="../../common.xml"/>
< /project>
< / pre >
< p > 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.
< / p >
<!-- manually written -->
2003-05-14 09:57:38 +00:00
< / blockquote > < / td > < / tr >
< / table >
2003-03-26 17:55:37 +00:00
< / td >
< / tr >
<!-- END RIGHT SIDE MAIN BODY -->
<!-- FOOTER SEPARATOR -->
< tr >
< td >
< hr noshade = "" size = "1" / >
< / td >
< / tr >
<!-- PAGE FOOTER -->
< tr >
< td >
< div align = "center" > < font color = "#525D76" size = "-1" > < em >
2004-11-19 09:07:12 +00:00
Copyright © 2000-2004, The Apache Software Foundation. All Rights Reserved.
2003-03-26 17:55:37 +00:00
< / em > < / font > < / div >
< / td >
< / tr >
< / table >
< / body >
2004-09-01 16:11:14 +00:00
< / html >