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.1 kB

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