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 10 KiB

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