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

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