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

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