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 8.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 no be used outside of a
  11. <code>target</code> if it invoces 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. regardless of the setting of <i>inheritAll</i>. This allows you to
  28. parameterize your subprojects. Properties defined on the command line
  29. can not be overridden by nested &lt;property&gt; elements.</p>
  30. <p>References to data types can also be passed to the new project, but
  31. by default they are not. If you set the inheritrefs attribute to
  32. true, all references will be copied, but they will not override
  33. references defined in the new project.</p>
  34. <p>Nested <a href="#reference"><i>&lt;reference&gt;</i></a> elements
  35. can also be used to copy references from the calling project to the
  36. new project, optionally under a different id. References taken from
  37. nested elements will override existing references that have been
  38. defined outside of targets in the new project - but not those defined
  39. inside of targets.</p>
  40. <h3>Parameters</h3>
  41. <table border="1" cellpadding="2" cellspacing="0">
  42. <tr>
  43. <td valign="top"><b>Attribute</b></td>
  44. <td valign="top"><b>Description</b></td>
  45. <td align="center" valign="top"><b>Required</b></td>
  46. </tr>
  47. <tr>
  48. <td valign="top">antfile</td>
  49. <td valign="top">the buildfile to use. Defaults to
  50. &quot;build.xml&quot;. This file is expected to be a filename
  51. relative to the dir attribute given.</td>
  52. <td valign="top" align="center">No</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">dir</td>
  56. <td valign="top">the directory to use as a basedir for the new Ant project.
  57. Defaults to the current project's basedir, unless
  58. inheritall has been set to false, in which case it doesn't
  59. have a default value. This will override the basedir
  60. setting of the called project.</td>
  61. <td valign="top" align="center">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">target</td>
  65. <td valign="top">the target of the new Ant project that should be executed.
  66. Defaults to the new project's default target.</td>
  67. <td valign="top" align="center">No</td>
  68. </tr>
  69. <tr>
  70. <td valign="top">output</td>
  71. <td valign="top">Filename to write the ant output to. This is
  72. relative to the value of the dir attribute if it has been set or
  73. to the base directory of the current project otherwise.
  74. </td>
  75. <td align="center" valign="top">No</td>
  76. </tr>
  77. <tr>
  78. <td valign="top">inheritAll</td>
  79. <td valign="top">If <code>true</code>, pass all properties to the
  80. new Ant project. Defaults to <code>true</code>.</td>
  81. <td align="center" valign="top">No</td>
  82. </tr>
  83. <tr>
  84. <td valign="top">inheritRefs</td>
  85. <td valign="top">If <code>true</code>, pass all references to the
  86. new Ant project. Defaults to <code>false</code>.</td>
  87. <td align="center" valign="top">No</td>
  88. </tr>
  89. </table>
  90. <h3>Parameters specified as nested elements</h3>
  91. <h4>property</h4>
  92. <p>See the description of the <a href="property.html">property
  93. task</a>. Note that the <code>refid</code> attribute points to a
  94. reference in the calling project, not in the new one.</p>
  95. <h4><a name="reference">reference</a></h4>
  96. <p>Used to chose references that shall be copied into the new project,
  97. optionally changing their id.</p>
  98. <table border="1" cellpadding="2" cellspacing="0">
  99. <tr>
  100. <td valign="top"><b>Attribute</b></td>
  101. <td valign="top"><b>Description</b></td>
  102. <td align="center" valign="top"><b>Required</b></td>
  103. </tr>
  104. <tr>
  105. <td valign="top">refid</td>
  106. <td valign="top">The id of the reference in the calling project.</td>
  107. <td valign="top" align="center">Yes</td>
  108. </tr>
  109. <tr>
  110. <td valign="top">torefid</td>
  111. <td valign="top">The id of the reference in the new project.</td>
  112. <td valign="top" align="center">No, defaults to the value of refid.</td>
  113. </tr>
  114. </table>
  115. <h4>propertyset</h4>
  116. <p>You can specify a set of properties to be copied into the new
  117. project with <a
  118. href="../CoreTypes/propertyset.html">propertyset</a>s.</p>
  119. <p><em>since Ant 1.6</em>.</p>
  120. <h3>Basedir of the new project</h3>
  121. <p>The basedir value of the new project is affected by the two
  122. attributes dir and inheritall, see the following table for
  123. details:</p>
  124. <table border="1" cellpadding="2" cellspacing="0">
  125. <tr>
  126. <td valign="top"><b>dir attribute</b></td>
  127. <td valign="top"><b>inheritAll attribute</b></td>
  128. <td valign="top"><b>new project's basedir</b></td>
  129. </tr>
  130. <tr>
  131. <td valign="top">value provided</td>
  132. <td valign="top">true</td>
  133. <td valign="top">value of dir attribute</td>
  134. </tr>
  135. <tr>
  136. <td valign="top">value provided</td>
  137. <td valign="top">false</td>
  138. <td valign="top">value of dir attribute</td>
  139. </tr>
  140. <tr>
  141. <td valign="top">omitted</td>
  142. <td valign="top">true</td>
  143. <td valign="top">basedir of calling project (the one whose build
  144. file contains the &lt;ant&gt; task).</td>
  145. </tr>
  146. <tr>
  147. <td valign="top">omitted</td>
  148. <td valign="top">false</td>
  149. <td valign="top">basedir attribute of the &lt;project&gt; element
  150. of the new project</td>
  151. </tr>
  152. </table>
  153. <h3>Examples</h3>
  154. <pre>
  155. &lt;ant antfile=&quot;subproject/subbuild.xml&quot; dir=&quot;subproject&quot; target=&quot;compile&quot;/&gt;
  156. &lt;ant dir=&quot;subproject&quot;/&gt;
  157. &lt;ant antfile=&quot;subproject/property_based_subbuild.xml&quot;&gt;
  158. &lt;property name=&quot;param1&quot; value=&quot;version 1.x&quot;/&gt;
  159. &lt;property file=&quot;config/subproject/default.properties&quot;/&gt;
  160. &lt;/ant&gt;
  161. &lt;ant inheritAll=&quot;false&quot; antfile=&quot;subproject/subbuild.xml&quot;&gt;
  162. &lt;property name=&quot;output.type&quot; value=&quot;html&quot;/&gt;
  163. &lt;/ant&gt;
  164. </pre>
  165. <p>The build file of the calling project defines some
  166. <code>&lt;path&gt;</code> elements like this:</p>
  167. <pre>
  168. &lt;path id="path1"&gt;
  169. ...
  170. &lt;/path&gt;
  171. &lt;path id="path2"&gt;
  172. ...
  173. &lt;/path&gt;
  174. </pre>
  175. <p>and the called build file (<code>subbuild.xml</code>) also defines
  176. a <code>&lt;path&gt;</code> with the id <code>path1</code>, but
  177. <code>path2</code> is not defined:</p>
  178. <pre>
  179. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;true&quot;/&gt;
  180. </pre>
  181. <p>will not override <code>subbuild</code>'s definition of
  182. <code>path1</code>, but make the parent's definition of
  183. <code>path2</code> available in the subbuild.</p>
  184. <pre>
  185. &lt;ant antfile=&quot;subbuild.xml&quot;/&gt;
  186. </pre>
  187. <p>as well as</p>
  188. <pre>
  189. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;/&gt;
  190. </pre>
  191. <p>will neither override <code>path1</code> nor copy
  192. <code>path2</code>.</p>
  193. <pre>
  194. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;&gt;
  195. &lt;reference refid=&quot;path1&quot;/&gt;
  196. &lt;/ant&gt;
  197. </pre>
  198. <p>will override <code>subbuild</code>'s definition of
  199. <code>path1</code>.</p>
  200. <pre>
  201. &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;&gt;
  202. &lt;reference refid=&quot;path1&quot; torefid=&quot;path2&quot;/&gt;
  203. &lt;/ant&gt;
  204. </pre>
  205. <p>will copy the parent's definition of <code>path1</code> into the
  206. new project using the id <code>path2</code>.</p>
  207. <hr>
  208. <p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All rights
  209. Reserved.</p>
  210. </body>
  211. </html>