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.

antcall.html 7.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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>AntCall Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="antcall">AntCall</a></h2>
  23. <h3>Description</h3>
  24. <p>Call another target within the same buildfile optionally
  25. specifying some properties (params in this context). <strong>This
  26. task must not be used outside of a <code>target</code>.</strong></p>
  27. <p>By default, all of the properties of the current project will be
  28. available in the new project. Alternatively, you can
  29. set the <i>inheritAll</i> attribute to <code>false</code> and only
  30. &quot;user&quot; properties (i.e., those passed on the command-line)
  31. will be passed to the new project. In either case, the set of
  32. properties passed to the new project will override the properties that
  33. are set in the new project (See also the <a href="property.html">property task</a>).</p>
  34. <p>You can also set properties in the new project from the old project
  35. by using nested param tags. These properties are always passed
  36. to the new project and any project created in that project
  37. regardless of the setting of <i>inheritAll</i>. This allows you to
  38. parameterize your subprojects. Properties defined on the command line
  39. can not be overridden by nested <code>&lt;param&gt;</code> elements.</p>
  40. <p>Nested <a href="#reference"><i><code>&lt;reference&gt</code>;</i></a> elements can
  41. be used to copy references from the calling project to the new
  42. project, optionally under a different id. References taken from
  43. nested elements will override existing references that have been
  44. defined outside of targets in the new project - but not those defined
  45. inside of targets.</p>
  46. <p>
  47. When a target is invoked by antcall, all of its dependent targets will
  48. also be called within the context of any new parameters. For example. if
  49. the target &quot;doSomethingElse&quot; depended on the target &quot;init&quot;, then the
  50. <i>antcall</i> of &quot;doSomethingElse&quot; will call &quot;init&quot; during the call.
  51. Of course, any properties defined in the antcall task or inherited from the calling target
  52. will be fixed and not overridable in the init task--or indeed in the &quot;doSomethingElse&quot; task.
  53. </p>
  54. <p>If the build file changes after you've started the build, the
  55. behavior of this task is undefined.</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">target</td>
  65. <td valign="top">The target to execute.</td>
  66. <td valign="top" align="center">Yes</td>
  67. </tr>
  68. <tr>
  69. <td valign="top">inheritAll</td>
  70. <td valign="top">If <code>true</code>, pass all properties to the new Ant
  71. project. Defaults to <code>true</code>.
  72. </td>
  73. <td align="center" valign="top">No</td>
  74. </tr>
  75. <tr>
  76. <td valign="top">inheritRefs</td>
  77. <td valign="top">If <code>true</code>, pass all references to the
  78. new Ant project. Defaults to <code>false</code>.</td>
  79. <td align="center" valign="top">No</td>
  80. </tr>
  81. </table>
  82. <h3>Note on <code>inheritRefs</code></h3>
  83. <p><code>&lt;antcall&gt;</code> will not override existing references,
  84. even if you set <code>inheritRefs</code> to true. As the called build
  85. files is the same build file as the calling one, this means it will
  86. not override any reference set via an <code>id</code> attribute at
  87. all. The only references that can be inherited by the child project
  88. are those defined by nested <code>&lt;reference&gt;</code> elements or
  89. references defined by tasks directly (not using the <code>id</code>
  90. attribute).</p>
  91. <h3>Parameters specified as nested elements</h3>
  92. <h4>param</h4>
  93. <p>Specifies the properties to set before running the specified target. See <a
  94. href="property.html">property</a> for usage guidelines.<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).
  99. </p>
  100. <h4><a name="reference">reference</a></h4>
  101. <p>Used to choose references that shall be copied into the new project,
  102. optionally changing their id.</p>
  103. <table border="1" cellpadding="2" cellspacing="0">
  104. <tr>
  105. <td valign="top"><b>Attribute</b></td>
  106. <td valign="top"><b>Description</b></td>
  107. <td align="center" valign="top"><b>Required</b></td>
  108. </tr>
  109. <tr>
  110. <td valign="top">refid</td>
  111. <td valign="top">The id of the reference in the calling project.</td>
  112. <td valign="top" align="center">Yes</td>
  113. </tr>
  114. <tr>
  115. <td valign="top">torefid</td>
  116. <td valign="top">The id of the reference in the new project.</td>
  117. <td valign="top" align="center">No, defaults to the value of refid.</td>
  118. </tr>
  119. </table>
  120. <h4>propertyset</h4>
  121. <p>You can specify a set of properties to be copied into the new
  122. project with <a
  123. href="../CoreTypes/propertyset.html">propertyset</a>s.</p>
  124. <p><em>since Ant 1.6</em>.</p>
  125. <h4>target</h4>
  126. <p>You can specify multiple targets using nested <code>&lt;target&gt;</code> elements
  127. instead of using the target attribute. These will be executed as if
  128. Ant had been invoked with a single target whose dependencies are the
  129. targets so specified, in the order specified.</p>
  130. <table border="1" cellpadding="2" cellspacing="0">
  131. <tr>
  132. <td valign="top"><b>Attribute</b></td>
  133. <td valign="top"><b>Description</b></td>
  134. <td align="center" valign="top"><b>Required</b></td>
  135. </tr>
  136. <tr>
  137. <td valign="top">name</td>
  138. <td valign="top">The name of the called target.</td>
  139. <td valign="top" align="center">Yes</td>
  140. </tr>
  141. </table>
  142. <p><em>since Ant 1.6.3</em>.</p>
  143. <h3>Examples</h3>
  144. <blockquote><pre>
  145. &lt;target name=&quot;default&quot;&gt;
  146. &lt;antcall target=&quot;doSomethingElse&quot;&gt;
  147. &lt;param name=&quot;param1&quot; value=&quot;value&quot;/&gt;
  148. &lt;/antcall&gt;
  149. &lt;/target&gt;
  150. &lt;target name=&quot;doSomethingElse&quot;&gt;
  151. &lt;echo message=&quot;param1=${param1}&quot;/&gt;
  152. &lt;/target&gt;
  153. </pre></blockquote>
  154. <p>Will run the target 'doSomethingElse' and echo 'param1=value'.</p>
  155. <blockquote><pre>
  156. &lt;antcall ... &gt;
  157. &lt;reference refid=&quot;path1&quot; torefid=&quot;path2&quot;/&gt;
  158. &lt;/antcall&gt;
  159. </pre></blockquote>
  160. <p>will copy the parent's definition of <code>path1</code> into the
  161. new project using the id <code>path2</code>.</p>
  162. </body>
  163. </html>