1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
<title>AntCall Task</title>
</head>
<body>
<h2><a name="antcall">AntCall</a></h2>
<h3>Description</h3>
<p>Call another target within the same buildfile optionally
specifying some properties (params in this context). <strong>This
task must not 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
"user" 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 <code><param></code> elements.</p>
<p>When more than one nested <code><param></code> element
would set a property of the same name, the one declared last will
win. This is for backwards compatibility reasons even so it is
different from the way <code><property></code> tasks in build
files behave.</p>
<p>Nested <a href="#reference"><i><code><reference></code>;</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 "doSomethingElse" depended on the target "init", then the
<i>antcall</i> of "doSomethingElse" will call "init" 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 "doSomethingElse" task.
</p>
<p>The called target(s) are run in a new project; be aware that this
means properties, references, etc. set by called targets will not
persist back to the calling project.</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 Apache 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><antcall></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><reference></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.<br>
These properties become equivalent to properties you define on
the command line. These are special properties and they will always get passed
down, even through additional <code><*ant*></code> tasks with inheritall set to
false (see above).
</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="../Types/propertyset.html">propertyset</a>s.</p>
<p><em>since Ant 1.6</em>.</p>
<h4>target</h4>
<p>You can specify multiple targets using nested <code><target></code> elements
instead of using the target attribute. These will be executed as if
Ant had been invoked with a single target whose dependencies are the
targets so specified, in the order specified.</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">name</td>
<td valign="top">The name of the called target.</td>
<td valign="top" align="center">Yes</td>
</tr>
</table>
<p><em>since Ant 1.6.3</em>.</p>
<h3>Examples</h3>
<blockquote><pre>
<target name="default">
<antcall target="doSomethingElse">
<param name="param1" value="value"/>
</antcall>
</target>
<target name="doSomethingElse">
<echo message="param1=${param1}"/>
</target>
</pre></blockquote>
<p>Will run the target 'doSomethingElse' and echo 'param1=value'.</p>
<blockquote><pre>
<antcall ... >
<reference refid="path1" torefid="path2"/>
</antcall>
</pre></blockquote>
<p>will copy the parent's definition of <code>path1</code> into the
new project using the id <code>path2</code>.</p>
</body>
</html>
|