You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

subant.html 23 KiB

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