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.

ant.html 9.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="ant">Ant</a></h2>
  8. <h3>Description</h3>
  9. <p>Runs Ant on a supplied buildfile. This can be used to build
  10. subprojects. <strong>This task must not be used outside of a
  11. <code>target</code> if it invokes the same build file it is part
  12. of.</strong></p>
  13. <p>When the <i>antfile</i> attribute is omitted, the file &quot;build.xml&quot;
  14. in the supplied directory (<i>dir</i> attribute) is used.</p>
  15. <p>If no target attribute is supplied, the default target of the new project is
  16. used.</p>
  17. <p>By default, all of the properties of the current project will be
  18. available in the new project. Alternatively, you can set the
  19. <i>inheritAll</i> attribute to <code>false</code> and only
  20. &quot;user&quot; properties (i.e., those passed on the command-line)
  21. will be passed to the new project. In either case, the set of
  22. properties passed to the new project will override the properties that
  23. are set in the new project (See also the <a
  24. href="property.html">property task</a>).</p>
  25. <p>You can also set properties in the new project from the old project
  26. by using nested property tags. These properties are always passed
  27. to the new project and any project created in that project
  28. regardless of the setting of <i>inheritAll</i>. This allows you to
  29. parameterize your subprojects. Properties defined on the command line
  30. cannot be overridden by nested <code>&lt;property&gt;</code> elements.</p>
  31. <p>References to data types can also be passed to the new project, but
  32. by default they are not. If you set the inheritrefs attribute to
  33. true, all references will be copied, but they will not override
  34. references defined in the new project.</p>
  35. <p>Nested <a href="#reference"><i><code>&lt;reference&gt;</code></i></a> elements
  36. can also be used to copy references from the calling project to the
  37. new project, optionally under a different id. References taken from
  38. nested elements will override existing references that have been
  39. defined outside of targets in the new project - but not those defined
  40. inside of targets.</p>
  41. <h3>Parameters</h3>
  42. <table border="1" cellpadding="2" cellspacing="0">
  43. <tr>
  44. <td valign="top"><b>Attribute</b></td>
  45. <td valign="top"><b>Description</b></td>
  46. <td align="center" valign="top"><b>Required</b></td>
  47. </tr>
  48. <tr>
  49. <td valign="top">antfile</td>
  50. <td valign="top">the buildfile to use. Defaults to
  51. &quot;build.xml&quot;. This file is expected to be a filename
  52. relative to the dir attribute given.</td>
  53. <td valign="top" align="center">No</td>
  54. </tr>
  55. <tr>
  56. <td valign="top">dir</td>
  57. <td valign="top">the directory to use as a basedir for the new Ant project.
  58. Defaults to the current project's basedir, unless
  59. inheritall has been set to false, in which case it doesn't
  60. have a default value. This will override the basedir
  61. setting of the called project.</td>
  62. <td valign="top" align="center">No</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">target</td>
  66. <td valign="top">the target of the new Ant project that should be executed.
  67. Defaults to the new project's default target.</td>
  68. <td valign="top" align="center">No</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">output</td>
  72. <td valign="top">Filename to write the ant output to. This is
  73. relative to the value of the dir attribute if it has been set or
  74. to the base directory of the current project otherwise.
  75. </td>
  76. <td align="center" valign="top">No</td>
  77. </tr>
  78. <tr>
  79. <td valign="top">inheritAll</td>
  80. <td valign="top">If <code>true</code>, pass all properties to the
  81. new Ant project. Defaults to <code>true</code>.</td>
  82. <td align="center" valign="top">No</td>
  83. </tr>
  84. <tr>
  85. <td valign="top">inheritRefs</td>
  86. <td valign="top">If <code>true</code>, pass all references to the
  87. new Ant project. Defaults to <code>false</code>.</td>
  88. <td align="center" valign="top">No</td>
  89. </tr>
  90. </table>
  91. <h3>Parameters specified as nested elements</h3>
  92. <h4>property</h4>
  93. <p>See the description of the <a href="property.html">property
  94. task</a>. <br/>
  95. These properties become equivalent to properties you define on
  96. the command line. These are special properties and they will always get passed
  97. down, even through additional <code>&lt;*ant*&gt;</code> tasks with inheritall set to
  98. false (see above). <br/>
  99. Note that the <code>refid</code> attribute points to a
  100. reference in the calling project, not in the new one.</p>
  101. <h4><a name="reference">reference</a></h4>
  102. <p>Used to choose references that shall be copied into the new project,
  103. optionally changing their id.</p>
  104. <table border="1" cellpadding="2" cellspacing="0">
  105. <tr>
  106. <td valign="top"><b>Attribute</b></td>
  107. <td valign="top"><b>Description</b></td>
  108. <td align="center" valign="top"><b>Required</b></td>
  109. </tr>
  110. <tr>
  111. <td valign="top">refid</td>
  112. <td valign="top">The id of the reference in the calling project.</td>
  113. <td valign="top" align="center">Yes</td>
  114. </tr>
  115. <tr>
  116. <td valign="top">torefid</td>
  117. <td valign="top">The id of the reference in the new project.</td>
  118. <td valign="top" align="center">No, defaults to the value of refid.</td>
  119. </tr>
  120. </table>
  121. <h4>propertyset</h4>
  122. <p>You can specify a set of properties to be copied into the new
  123. project with <a
  124. href="../CoreTypes/propertyset.html">propertyset</a>s.</p>
  125. <p><em>since Ant 1.6</em>.</p>
  126. <h4>target</h4>
  127. <p>You can specify multiple targets using nested <code>&lt;target&gt;</code> elements
  128. instead of using the target attribute. These will be executed as if
  129. Ant had been invoked with a single target whose dependencies are the
  130. targets so specified, in the order specified.</p>
  131. <table border="1" cellpadding="2" cellspacing="0">
  132. <tr>
  133. <td valign="top"><b>Attribute</b></td>
  134. <td valign="top"><b>Description</b></td>
  135. <td align="center" valign="top"><b>Required</b></td>
  136. </tr>
  137. <tr>
  138. <td valign="top">name</td>
  139. <td valign="top">The name of the called target.</td>
  140. <td valign="top" align="center">Yes</td>
  141. </tr>
  142. </table>
  143. <p><em>since Ant 1.6.3</em>.</p>
  144. <h3>Basedir of the new project</h3>
  145. <p>The basedir value of the new project is affected by the two
  146. attributes dir and inheritall, see the following table for
  147. details:</p>
  148. <table border="1" cellpadding="2" cellspacing="0">
  149. <tr>
  150. <td valign="top"><b>dir attribute</b></td>
  151. <td valign="top"><b>inheritAll attribute</b></td>
  152. <td valign="top"><b>new project's basedir</b></td>
  153. </tr>
  154. <tr>
  155. <td valign="top">value provided</td>
  156. <td valign="top">true</td>
  157. <td valign="top">value of dir attribute</td>
  158. </tr>
  159. <tr>
  160. <td valign="top">value provided</td>
  161. <td valign="top">false</td>
  162. <td valign="top">value of dir attribute</td>
  163. </tr>
  164. <tr>
  165. <td valign="top">omitted</td>
  166. <td valign="top">true</td>
  167. <td valign="top">basedir of calling project (the one whose build
  168. file contains the <code>&lt;ant&gt;</code> task).</td>
  169. </tr>
  170. <tr>
  171. <td valign="top">omitted</td>
  172. <td valign="top">false</td>
  173. <td valign="top">basedir attribute of the <code>&lt;project&gt;</code> element
  174. of the new project</td>
  175. </tr>
  176. </table>
  177. <h3>Examples</h3>
  178. <pre>
  179. &lt;ant antfile=&quot;subproject/subbuild.xml&quot; dir=&quot;subproject&quot; target=&quot;compile&quot;/&gt;
  180. &lt;ant dir=&quot;subproject&quot;/&gt;
  181. &lt;ant antfile=&quot;subproject/property_based_subbuild.xml&quot;&gt;
  182. &lt;property name=&quot;param1&quot; value=&quot;version 1.x&quot;/&gt;
  183. &lt;property file=&quot;config/subproject/default.properties&quot;/&gt;
  184. &lt;/ant&gt;
  185. &lt;ant inheritAll=&quot;false&quot; antfile=&quot;subproject/subbuild.xml&quot;&gt;
  186. &lt;property name=&quot;output.type&quot; value=&quot;html&quot;/&gt;
  187. &lt;/ant&gt;
  188. </pre>
  189. <p>The build file of the calling project defines some
  190. <code>&lt;path&gt;</code> elements like this:</p>
  191. <pre>
  192. &lt;path id="path1"&gt;
  193. ...
  194. &lt;/path&gt;
  195. &lt;path id="path2"&gt;
  196. ...
  197. &lt;/path&gt;
  198. </pre>
  199. <p>and the called build file (<code>subbuild.xml</code>) also defines
  200. a <code>&lt;path&gt;</code> with the id <code>path1</code>, but
  201. <code>path2</code> is not defined:</p>
  202. <pre>
  203. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;true&quot;/&gt;
  204. </pre>
  205. <p>will not override <code>subbuild</code>'s definition of
  206. <code>path1</code>, but make the parent's definition of
  207. <code>path2</code> available in the subbuild.</p>
  208. <pre>
  209. &lt;ant antfile=&quot;subbuild.xml&quot;/&gt;
  210. </pre>
  211. <p>as well as</p>
  212. <pre>
  213. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;/&gt;
  214. </pre>
  215. <p>will neither override <code>path1</code> nor copy
  216. <code>path2</code>.</p>
  217. <pre>
  218. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;&gt;
  219. &lt;reference refid=&quot;path1&quot;/&gt;
  220. &lt;/ant&gt;
  221. </pre>
  222. <p>will override <code>subbuild</code>'s definition of
  223. <code>path1</code>.</p>
  224. <pre>
  225. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;&gt;
  226. &lt;reference refid=&quot;path1&quot; torefid=&quot;path2&quot;/&gt;
  227. &lt;/ant&gt;
  228. </pre>
  229. <p>will copy the parent's definition of <code>path1</code> into the
  230. new project using the id <code>path2</code>.</p>
  231. <hr>
  232. <p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
  233. Reserved.</p>
  234. </body>
  235. </html>