blob: 42c343871ee9c8470e18008406aa117536d8a0ef [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>AntCall Task</title>
<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
</head>
<body>
<h2><a name="antcall">AntCall</a></h2>
<h3>Description</h3>
<p>Call another target within the same build-file optionally
specifying some properties (param's in this context). <strong>This
task must no be used outside of a <code>target</code>.</strong></p>
<p>By default, all of the properties of the current project will be
available in the new project. Alternatively, you can
set the <i>inheritAll</i> attribute to <code>false</code> and only
&quot;user&quot; properties (i.e., those passed on the command-line)
will be passed to the new project. In either case, the set of
properties passed to the new project will override the properties that
are set in the new project (See also the <a href="property.html">property task</a>).</p>
<p>You can also set properties in the new project from the old project
by using nested param tags. These properties are always passed
to the new project and any project created in that project
regardless of the setting of <i>inheritAll</i>. This allows you to
parameterize your subprojects. Properties defined on the command line
can not be overridden by nested &lt;param&gt; elements.</p>
<p>Nested <a href="#reference"><i>&lt;reference&gt;</i></a> elements can
be used to copy references from the calling project to the new
project, optionally under a different id. References taken from
nested elements will override existing references that have been
defined outside of targets in the new project - but not those defined
inside of targets.</p>
<p>
When a target is invoked by antcall, all of its dependent targets will
also be called within the context of any new parameters. For example. if
the target &quot;doSomethingElse&quot; depended on the target &quot;init&quot;, then the
<i>antcall</i> of &quot;doSomethingElse&quot; will call &quot;init&quot; during the call.
Of course, any properties defined in the antcall task or inherited from the calling target
will be fixed and not overridable in the init task -or indeed in the &quot;doSomethingElse&quot; task.
</p>
<p>If the build file changes after you've started the build, the
behavior of this task is undefined.</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">target</td>
<td valign="top">The target to execute.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">inheritAll</td>
<td valign="top">If <code>true</code>, pass all properties to the new Ant
project. Defaults to <code>true</code>.
</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">inheritRefs</td>
<td valign="top">If <code>true</code>, pass all references to the
new Ant project. Defaults to <code>false</code>.</td>
<td align="center" valign="top">No</td>
</tr>
</table>
<h3>Note on <code>inheritRefs</code></h3>
<p><code>&lt;antcall&gt;</code> will not override existing references,
even if you set <code>inheritRefs</code> to true. As the called build
files is the same build file as the calling one, this means it will
not override any reference set via an <code>id</code> attribute at
all. The only references that can be inherited by the child project
are those defined by nested <code>&lt;reference&gt;</code> elements or
references defined by tasks directly (not using the <code>id</code>
attribute).</p>
<h3>Parameters specified as nested elements</h3>
<h4>param</h4>
<p>Specifies the properties to set before running the specified target. See <a
href="property.html">property</a> for usage guidelines.</p>
<h4><a name="reference">reference</a></h4>
<p>Used to choose references that shall be copied into the new project,
optionally changing their id.</p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">refid</td>
<td valign="top">The id of the reference in the calling project.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">torefid</td>
<td valign="top">The id of the reference in the new project.</td>
<td valign="top" align="center">No, defaults to the value of refid.</td>
</tr>
</table>
<h4>propertyset</h4>
<p>You can specify a set of properties to be copied into the new
project with <a
href="../CoreTypes/propertyset.html">propertyset</a>s.</p>
<p><em>since Ant 1.6</em>.</p>
<h3>Examples</h3>
<pre>
&lt;target name=&quot;default&quot;&gt;
&lt;antcall target=&quot;doSomethingElse&quot;&gt;
&lt;param name=&quot;param1&quot; value=&quot;value&quot;/&gt;
&lt;/antcall&gt;
&lt;/target&gt;
&lt;target name=&quot;doSomethingElse&quot;&gt;
&lt;echo message=&quot;param1=${param1}&quot;/&gt;
&lt;/target&gt;
</pre>
<p>Will run the target 'doSomethingElse' and echo 'param1=value'.</p>
<pre>
&lt;antcall ... &gt;
&lt;reference refid=&quot;path1&quot; torefid=&quot;path2&quot;/&gt;
&lt;/antcall&gt;
</pre>
<p>will copy the parent's definition of <code>path1</code> into the
new project using the id <code>path2</code>.</p>
<hr><p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All rights
Reserved.</p>
</body>
</html>