source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTasks/subant.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 19.3 KB
Line 
1
2<html>
3<head>
4 <meta http-equiv="Content-Language" content="en-us">
5 <title>Subant
6 Task</title>
7<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
8</head>
9
10<body bgcolor="#ffffff" text="#000000" link="#525D76"
11 alink="#525D76" vlink="#525D76">
12
13<table border="0" width="100%" cellspacing="4">
14
15 <!-- PAGE HEADER -->
16 <tr>
17 <td>
18 <table border="0" width="100%"><tr>
19 <td valign="bottom">
20 <font size="+3" face="arial,helvetica,sanserif"><strong>Subant
21 Task</strong></font>
22 <br><font face="arial,helvetica,sanserif">Calls a given target for all defined sub-builds.</font>
23 </td>
24 <td>
25 <!-- PROJECT LOGO -->
26 <a href="http://ant.apache.org/">
27 <img src="../../images/ant_logo_large.gif" align="right" alt="Apache Ant" border="0"/>
28 </a>
29 </td>
30 </tr></table>
31 </td>
32 </tr>
33
34 <!-- START RIGHT SIDE MAIN BODY -->
35 <tr>
36 <td valign="top" align="left">
37
38 <!-- Applying task/description -->
39 <!-- Start Description -->
40 <table border="0" cellspacing="0" cellpadding="2" width="100%">
41 <tr><td>&nbsp;</td></tr>
42
43 <tr><td bgcolor="#525D76">
44 <font color="#ffffff" face="arial,helvetica.sanserif">
45 <a name="description">
46 <strong>Description</strong></a></font>
47 </td></tr>
48
49 <tr><td><blockquote>
50<p>
51 Calls a given target for all defined sub-builds.
52 This is an extension
53 of ant for bulk project execution.
54
55 <strong>This task must no be used outside of a
56 <code>target</code> if it invokes the same build file it is
57 part of.</strong>
58 </p>
59 <table border="0" cellspacing="0" cellpadding="2" width="100%">
60 <!-- Subsection heading -->
61 <tr><td bgcolor="#828DA6">
62 <font color="#ffffff" face="arial,helvetica.sanserif">
63 <a name="Use with directories">
64 <strong>Use with directories</strong></a></font>
65 </td></tr>
66 <!-- Subsection body -->
67 <tr><td>
68 <p>
69 subant can be used with directory sets to execute a build from different directories.
70 2 different options are offered :
71 </p>
72<ul>
73 <li>
74 to run the same build file <code>/somepath/otherpath/mybuild.xml</code>
75 with different base directories, use the genericantfile attribute
76 </li>
77 <li>if you want to run <code>directory1/mybuild.xml</code>, <code>directory2/mybuild.xml</code>, <code>....</code>,
78 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.
79 </li>
80 </ul>
81
82 </td></tr>
83 </table>
84
85 </blockquote></td></tr>
86
87 </table>
88 <!-- End Description -->
89
90 <!-- Ignore -->
91
92
93
94 <!-- Start Attributes -->
95 <table border="0" cellspacing="0" cellpadding="2" width="100%">
96 <tr><td>&nbsp;</td></tr>
97 <tr><td bgcolor="#525D76">
98 <font color="#ffffff" face="arial,helvetica.sanserif">
99 <a name="attributes">
100 <strong>Parameters</strong></a></font>
101 </td></tr>
102 <tr><td><blockquote>
103 <table>
104 <tr>
105 <td bgcolor="#cccccc" valign="top" align="left">
106 <font color="#000000" size="-1" face="arial,helvetica,sanserif"><b>Attribute</b></font>
107 </td>
108 <td bgcolor="#cccccc" valign="top" align="left">
109 <font color="#000000" size="-1" face="arial,helvetica,sanserif"><b>Description</b></font>
110 </td>
111 <td bgcolor="#cccccc" valign="top" align="left">
112 <font color="#000000" size="-1" face="arial,helvetica,sanserif"><b>Type</b></font>
113 </td>
114 <td bgcolor="#cccccc" valign="top" align="left">
115 <font color="#000000" size="-1" face="arial,helvetica,sanserif"><b>Requirement</b></font>
116 </td>
117 </tr>
118 <!-- Attribute Group -->
119
120 <!-- Attribute Group -->
121 <!-- Attribute -->
122 <tr>
123 <td bgcolor="#eeeeee" valign="top" align="left">
124 <font color="#000000" size="-1" face="arial,helvetica,sanserif">antfile</font>
125 </td>
126 <td bgcolor="#eeeeee" valign="top" align="left">
127 <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>
128 </td>
129 <td bgcolor="#eeeeee" valign="top" align="left">
130 <font color="#000000" size="-1" face="arial,helvetica,sanserif">String</font>
131 </td>
132 <td bgcolor="#eeeeee" valign="top" align="left" rowspan="10">
133 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Optional</font>
134 </td>
135 </tr>
136 <!-- Attribute -->
137 <tr>
138 <td bgcolor="#eeeeee" valign="top" align="left">
139 <font color="#000000" size="-1" face="arial,helvetica,sanserif">buildpath</font>
140 </td>
141 <td bgcolor="#eeeeee" valign="top" align="left">
142 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Set the buildpath to be used to find sub-projects.</font>
143 </td>
144 <td bgcolor="#eeeeee" valign="top" align="left">
145 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Path</font>
146 </td>
147 </tr>
148 <!-- Attribute -->
149 <tr>
150 <td bgcolor="#eeeeee" valign="top" align="left">
151 <font color="#000000" size="-1" face="arial,helvetica,sanserif">buildpathref</font>
152 </td>
153 <td bgcolor="#eeeeee" valign="top" align="left">
154 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Buildpath to use, by reference.</font>
155 </td>
156 <td bgcolor="#eeeeee" valign="top" align="left">
157 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Reference</font>
158 </td>
159 </tr>
160 <!-- Attribute -->
161 <tr>
162 <td bgcolor="#eeeeee" valign="top" align="left">
163 <font color="#000000" size="-1" face="arial,helvetica,sanserif">failonerror</font>
164 </td>
165 <td bgcolor="#eeeeee" valign="top" align="left">
166 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Sets whether to fail with a build exception on error, or go on.</font>
167 </td>
168 <td bgcolor="#eeeeee" valign="top" align="left">
169 <font color="#000000" size="-1" face="arial,helvetica,sanserif">boolean</font>
170 </td>
171 </tr>
172 <!-- Attribute -->
173 <tr>
174 <td bgcolor="#eeeeee" valign="top" align="left">
175 <font color="#000000" size="-1" face="arial,helvetica,sanserif">genericantfile</font>
176 </td>
177 <td bgcolor="#eeeeee" valign="top" align="left">
178 <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>
179 </td>
180 <td bgcolor="#eeeeee" valign="top" align="left">
181 <font color="#000000" size="-1" face="arial,helvetica,sanserif">File</font>
182 </td>
183 </tr>
184 <!-- Attribute -->
185 <tr>
186 <td bgcolor="#eeeeee" valign="top" align="left">
187 <font color="#000000" size="-1" face="arial,helvetica,sanserif">inheritall</font>
188 </td>
189 <td bgcolor="#eeeeee" valign="top" align="left">
190 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Corresponds to <code>&lt;ant&gt;</code>'s <code>inheritall</code> attribute.</font>
191 </td>
192 <td bgcolor="#eeeeee" valign="top" align="left">
193 <font color="#000000" size="-1" face="arial,helvetica,sanserif">boolean</font>
194 </td>
195 </tr>
196 <!-- Attribute -->
197 <tr>
198 <td bgcolor="#eeeeee" valign="top" align="left">
199 <font color="#000000" size="-1" face="arial,helvetica,sanserif">inheritrefs</font>
200 </td>
201 <td bgcolor="#eeeeee" valign="top" align="left">
202 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Corresponds to <code>&lt;ant&gt;</code>'s <code>inheritrefs</code> attribute.</font>
203 </td>
204 <td bgcolor="#eeeeee" valign="top" align="left">
205 <font color="#000000" size="-1" face="arial,helvetica,sanserif">boolean</font>
206 </td>
207 </tr>
208 <!-- Attribute -->
209 <tr>
210 <td bgcolor="#eeeeee" valign="top" align="left">
211 <font color="#000000" size="-1" face="arial,helvetica,sanserif">output</font>
212 </td>
213 <td bgcolor="#eeeeee" valign="top" align="left">
214 <font color="#000000" size="-1" face="arial,helvetica,sanserif">Corresponds to <code>&lt;ant&gt;</code>'s <code>output</code> attribute.</font>
215 </td>
216 <td bgcolor="#eeeeee" valign="top" align="left">
217 <font color="#000000" size="-1" face="arial,helvetica,sanserif">String</font>
218 </td>
219 </tr>
220 <!-- Attribute -->
221 <tr>
222 <td bgcolor="#eeeeee" valign="top" align="left">
223 <font color="#000000" size="-1" face="arial,helvetica,sanserif">target</font>
224 </td>
225 <td bgcolor="#eeeeee" valign="top" align="left">
226 <font color="#000000" size="-1" face="arial,helvetica,sanserif"></font>
227 </td>
228 <td bgcolor="#eeeeee" valign="top" align="left">
229 <font color="#000000" size="-1" face="arial,helvetica,sanserif">String</font>
230 </td>
231 </tr>
232
233 <!-- Attribute -->
234 <tr>
235 <td bgcolor="#eeeeee" valign="top" align="left">
236 <font color="#000000" size="-1" face="arial,helvetica,sanserif">verbose</font>
237 </td>
238 <td bgcolor="#eeeeee" valign="top" align="left">
239 <font color="#000000" size="-1" face="arial,helvetica,sanserif">
240 Enable/ disable log messages showing when each sub-build path is entered/ exited.
241 The default value is false.</font>
242 </td>
243 <td bgcolor="#eeeeee" valign="top" align="left">
244 <font color="#000000" size="-1" face="arial,helvetica,sanserif">boolean</font>
245 </td>
246 </tr>
247
248
249 </table>
250 </blockquote></td></tr>
251
252 </table>
253 <!-- End Attributes -->
254
255 <!-- Start Elements -->
256 <table border="0" cellspacing="0" cellpadding="2" width="100%">
257 <tr><td>&nbsp;</td></tr>
258
259 <tr><td bgcolor="#525D76">
260 <font color="#ffffff" face="arial,helvetica.sanserif">
261 <a name="elements">
262 <strong>Parameters as nested elements</strong></a></font>
263 </td></tr>
264
265 <tr><td><blockquote>
266 <!-- Start Element -->
267 <table border="0" cellspacing="0" cellpadding="2" width="100%">
268 <tr><td>&nbsp;</td></tr>
269 <tr><td bgcolor="#828DA6">
270 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
271 <strong>dirset</strong> (org.apache.tools.ant.types.DirSet)</font>
272 </td></tr>
273 <tr><td><blockquote>
274 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>
275 <!-- Ignore -->
276 <!-- Ignore -->
277
278 </blockquote></td></tr>
279 </table>
280 <!-- End Element -->
281 <!-- Start Element -->
282 <table border="0" cellspacing="0" cellpadding="2" width="100%">
283 <tr><td>&nbsp;</td></tr>
284 <tr><td bgcolor="#828DA6">
285 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
286 <strong>filelist</strong> (org.apache.tools.ant.types.FileList)</font>
287 </td></tr>
288 <tr><td><blockquote>
289 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>
290 <!-- Ignore -->
291 <!-- Ignore -->
292
293 </blockquote></td></tr>
294 </table>
295 <!-- End Element -->
296 <!-- Start Element -->
297 <table border="0" cellspacing="0" cellpadding="2" width="100%">
298 <tr><td>&nbsp;</td></tr>
299 <tr><td bgcolor="#828DA6">
300 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
301 <strong>fileset</strong> (org.apache.tools.ant.types.FileSet)</font>
302 </td></tr>
303 <tr><td><blockquote>
304 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>
305 <!-- Ignore -->
306 <!-- Ignore -->
307
308 </blockquote></td></tr>
309 </table>
310 <!-- End Element -->
311 <!-- Start Element -->
312 <table border="0" cellspacing="0" cellpadding="2" width="100%">
313 <tr><td>&nbsp;</td></tr>
314 <tr><td bgcolor="#828DA6">
315 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
316 <strong>property</strong> (org.apache.tools.ant.taskdefs.Property)</font>
317 </td></tr>
318 <tr><td><blockquote>
319 Corresponds to <code>&lt;ant&gt;</code>'s nested <code>&lt;property&gt;</code> element.
320 <!-- Ignore -->
321 <!-- Ignore -->
322
323 </blockquote></td></tr>
324 </table>
325 <!-- End Element -->
326 <!-- Start Element -->
327 <table border="0" cellspacing="0" cellpadding="2" width="100%">
328 <tr><td>&nbsp;</td></tr>
329 <tr><td bgcolor="#828DA6">
330 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
331 <strong>propertyset</strong> (org.apache.tools.ant.types.PropertySet)</font>
332 </td></tr>
333 <tr><td><blockquote>
334 Corresponds to <code>&lt;ant&gt;</code>'s nested <code>&lt;propertyset&gt;</code> element.
335 <!-- Ignore -->
336 <!-- Ignore -->
337
338 </blockquote></td></tr>
339 </table>
340 <!-- End Element -->
341 <!-- Start Element -->
342 <table border="0" cellspacing="0" cellpadding="2" width="100%">
343 <tr><td>&nbsp;</td></tr>
344 <tr><td bgcolor="#828DA6">
345 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
346 <strong>buildpath</strong> (org.apache.tools.ant.types.Path)</font>
347 </td></tr>
348 <tr><td><blockquote>
349 Creates a nested build path, and add it to the implicit build path.
350 <!-- Ignore -->
351 <!-- Ignore -->
352
353 </blockquote></td></tr>
354 </table>
355 <!-- End Element -->
356 <!-- Start Element -->
357 <table border="0" cellspacing="0" cellpadding="2" width="100%">
358 <tr><td>&nbsp;</td></tr>
359 <tr><td bgcolor="#828DA6">
360 <font color="#ffffff" face="arial,helvetica.sanserif" size="-1">
361 <strong>buildpathelement</strong> (org.apache.tools.ant.types.Path.PathElement)</font>
362 </td></tr>
363 <tr><td><blockquote>
364 Creates a nested <code>&lt;buildpathelement&gt;</code>, and add it to the implicit build path.
365 <!-- Ignore -->
366 <!-- Ignore -->
367
368 </blockquote></td></tr>
369 </table>
370 <!-- End Element -->
371
372 </blockquote></td></tr>
373
374 </table>
375 <!-- End Elements -->
376
377 <table border="0" cellspacing="0" cellpadding="2" width="100%">
378 <tr><td>&nbsp;</td></tr>
379
380 <tr><td bgcolor="#525D76">
381 <font color="#ffffff" face="arial,helvetica.sanserif">
382 <a name="examples">
383 <strong>Examples</strong></a></font>
384 </td></tr>
385
386 <tr><td><blockquote>
387 <pre>
388 &lt;project name="subant" default="subant1"&gt;
389 &lt;property name="build.dir" value="subant.build"/&gt;
390 &lt;target name="subant1"&gt;
391 &lt;subant target=""&gt;
392 &lt;property name="build.dir" value="subant1.build"/&gt;
393 &lt;property name="not.overloaded" value="not.overloaded"/&gt;
394 &lt;fileset dir="." includes="*/build.xml"/&gt;
395 &lt;/subant&gt;
396 &lt;/target&gt;
397 &lt;/project&gt;
398 </pre>
399<p>
400 this snippet build file will run ant in each subdirectory of the project directory,
401 where a file called build.xml can be found.
402 The property build.dir will have the value subant1.build in the ant projects called by subant.
403 </p>
404<pre>
405 &lt;subant target=""&gt;
406 &lt;propertyset&gt;
407 &lt;propertyref prefix="toplevel"/&gt;
408 &lt;mapper type="glob" from="foo*" to="bar*"/&gt;
409 &lt;/propertyset&gt;
410 &lt;fileset dir="." includes="*/build.xml"/&gt;
411 &lt;/subant&gt;
412 </pre>
413<p>
414 this snippet build file will run ant in each subdirectory of the project directory,
415 where a file called build.xml can be found.
416 All properties whose name starts with "foo" are passed, their names are changed to start with "bar" instead
417 </p>
418<pre>
419 &lt;subant target="compile" genericantfile="/opt/project/build1.xml"&gt;
420 &lt;dirset dir="." includes="projects*"/&gt;
421 &lt;/subant&gt;
422 </pre>
423<p>
424 assuming the subdirs of the project dir are called projects1, projects2, projects3
425 this snippet will execute the compile target of /opt/project/build1.xml,
426 setting the basedir to projects1, projects2, projects3
427 </p>
428
429 <!-- manually written -->
430 <p>Now a little more complex - but useful - scenario. Assume that we have
431 a directory structure like this:</p>
432 <pre>
433 root
434 | common.xml
435 | build.xml
436 |
437 +-- modules
438 +-- modA
439 | +-- src
440 +-- modB
441 +-- src
442
443 <u><b>common.xml:</b></u><br>
444 &lt;project&gt;
445 &lt;property name="src.dir" value="src"/&gt;
446 &lt;property name="build.dir" value="build"/&gt;
447 &lt;property name="classes.dir" value="${build.dir}/classes"/&gt;
448
449 &lt;target name="compile"&gt;
450 &lt;mkdir dir="${classes.dir}"/&gt;
451 &lt;javac srcdir="${src.dir}" destdir="${classes.dir}"/&gt;
452 &lt;/target&gt;
453
454 &lt;!-- more targets --&gt;
455 &lt;/project&gt;
456
457 <u><b>build.xml:</b></u><br>
458 &lt;project&gt;
459
460 &lt;macrodef name="iterate"&gt;
461 &lt;attribute name="target"/&gt;
462 &lt;sequential&gt;
463 &lt;subant target="@{target}"&gt;
464 &lt;fileset dir="modules" includes="*/build.xml"/&gt;
465 &lt;/subant&gt;
466 &lt;/sequential&gt;
467 &lt;/macrodef&gt;
468
469
470 &lt;target name="compile"&gt;
471 &lt;iterate target="compile"/&gt;
472 &lt;/target&gt;
473
474 &lt;!-- more targets --&gt;
475 &lt;/project&gt;
476
477 <u><b>modules/modA/build.xml:</b></u><br>
478 &lt;project name="modA"&gt;
479 &lt;import file="../../common.xml"/&gt;
480 &lt;/project&gt;
481 </pre>
482
483 <p>This results in very small buildfiles in the modules, maintainable
484 buildfile (common.xml) and a clear project structure. Additionally
485 the root buildfile is capable to run the whole build over all
486 modules.
487 </p>
488
489 <!-- manually written -->
490
491 </blockquote></td></tr>
492
493 </table>
494
495 </td>
496 </tr>
497 <!-- END RIGHT SIDE MAIN BODY -->
498
499 <!-- FOOTER SEPARATOR -->
500 <tr>
501 <td>
502 <hr noshade="" size="1"/>
503 </td>
504 </tr>
505
506 <!-- PAGE FOOTER -->
507 <tr>
508 <td>
509 <div align="center"><font color="#525D76" size="-1"><em>
510 Copyright &copy; 2000-2005, The Apache Software Foundation. All Rights Reserved.
511 </em></font></div>
512 </td>
513 </tr>
514
515</table>
516
517</body>
518</html>
Note: See TracBrowser for help on using the repository browser.