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

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