source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual1.6.2/manual/CoreTasks/ant.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 8.3 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Ant Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="ant">Ant</a></h2>
12<h3>Description</h3>
13
14<p>Runs Ant on a supplied buildfile. This can be used to build
15subprojects. <strong>This task must not be used outside of a
16<code>target</code> if it invoces the same build file it is part
17of.</strong></p>
18
19<p>When the <i>antfile</i> attribute is omitted, the file &quot;build.xml&quot;
20in the supplied directory (<i>dir</i> attribute) is used.</p>
21<p>If no target attribute is supplied, the default target of the new project is
22used.</p>
23<p>By default, all of the properties of the current project will be
24available in the new project. Alternatively, you can set the
25<i>inheritAll</i> attribute to <code>false</code> and only
26&quot;user&quot; properties (i.e., those passed on the command-line)
27will be passed to the new project. In either case, the set of
28properties passed to the new project will override the properties that
29are set in the new project (See also the <a
30href="property.html">property task</a>).</p>
31
32<p>You can also set properties in the new project from the old project
33by using nested property tags. These properties are always passed
34to the new project and any project created in that project
35regardless of the setting of <i>inheritAll</i>. This allows you to
36parameterize your subprojects. Properties defined on the command line
37can not be overridden by nested &lt;property&gt; elements.</p>
38
39<p>References to data types can also be passed to the new project, but
40by default they are not. If you set the inheritrefs attribute to
41true, all references will be copied, but they will not override
42references defined in the new project.</p>
43
44<p>Nested <a href="#reference"><i>&lt;reference&gt;</i></a> elements
45can also be used to copy references from the calling project to the
46new project, optionally under a different id. References taken from
47nested elements will override existing references that have been
48defined outside of targets in the new project - but not those defined
49inside of targets.</p>
50
51<h3>Parameters</h3>
52<table border="1" cellpadding="2" cellspacing="0">
53 <tr>
54 <td valign="top"><b>Attribute</b></td>
55 <td valign="top"><b>Description</b></td>
56 <td align="center" valign="top"><b>Required</b></td>
57 </tr>
58 <tr>
59 <td valign="top">antfile</td>
60 <td valign="top">the buildfile to use. Defaults to
61 &quot;build.xml&quot;. This file is expected to be a filename
62 relative to the dir attribute given.</td>
63 <td valign="top" align="center">No</td>
64 </tr>
65 <tr>
66 <td valign="top">dir</td>
67 <td valign="top">the directory to use as a basedir for the new Ant project.
68 Defaults to the current project's basedir, unless
69 inheritall has been set to false, in which case it doesn't
70 have a default value. This will override the basedir
71 setting of the called project.</td>
72 <td valign="top" align="center">No</td>
73 </tr>
74 <tr>
75 <td valign="top">target</td>
76 <td valign="top">the target of the new Ant project that should be executed.
77 Defaults to the new project's default target.</td>
78 <td valign="top" align="center">No</td>
79 </tr>
80 <tr>
81 <td valign="top">output</td>
82 <td valign="top">Filename to write the ant output to. This is
83 relative to the value of the dir attribute if it has been set or
84 to the base directory of the current project otherwise.
85 </td>
86 <td align="center" valign="top">No</td>
87 </tr>
88 <tr>
89 <td valign="top">inheritAll</td>
90 <td valign="top">If <code>true</code>, pass all properties to the
91 new Ant project. Defaults to <code>true</code>.</td>
92 <td align="center" valign="top">No</td>
93 </tr>
94 <tr>
95 <td valign="top">inheritRefs</td>
96 <td valign="top">If <code>true</code>, pass all references to the
97 new Ant project. Defaults to <code>false</code>.</td>
98 <td align="center" valign="top">No</td>
99 </tr>
100</table>
101
102<h3>Parameters specified as nested elements</h3>
103
104<h4>property</h4>
105<p>See the description of the <a href="property.html">property
106task</a>. Note that the <code>refid</code> attribute points to a
107reference in the calling project, not in the new one.</p>
108
109<a name="reference"></a><h4>reference</h4>
110<p>Used to choose references that shall be copied into the new project,
111optionally changing their id.</p>
112
113<table border="1" cellpadding="2" cellspacing="0">
114 <tr>
115 <td valign="top"><b>Attribute</b></td>
116 <td valign="top"><b>Description</b></td>
117 <td align="center" valign="top"><b>Required</b></td>
118 </tr>
119 <tr>
120 <td valign="top">refid</td>
121 <td valign="top">The id of the reference in the calling project.</td>
122 <td valign="top" align="center">Yes</td>
123 </tr>
124 <tr>
125 <td valign="top">torefid</td>
126 <td valign="top">The id of the reference in the new project.</td>
127 <td valign="top" align="center">No, defaults to the value of refid.</td>
128 </tr>
129</table>
130
131<h4>propertyset</h4>
132
133<p>You can specify a set of properties to be copied into the new
134project with <a
135href="../CoreTypes/propertyset.html">propertyset</a>s.</p>
136
137<p><em>since Ant 1.6</em>.</p>
138
139<h3>Basedir of the new project</h3>
140
141<p>The basedir value of the new project is affected by the two
142attributes dir and inheritall, see the following table for
143details:</p>
144
145<table border="1" cellpadding="2" cellspacing="0">
146 <tr>
147 <td valign="top"><b>dir attribute</b></td>
148 <td valign="top"><b>inheritAll attribute</b></td>
149 <td valign="top"><b>new project's basedir</b></td>
150 </tr>
151 <tr>
152 <td valign="top">value provided</td>
153 <td valign="top">true</td>
154 <td valign="top">value of dir attribute</td>
155 </tr>
156 <tr>
157 <td valign="top">value provided</td>
158 <td valign="top">false</td>
159 <td valign="top">value of dir attribute</td>
160 </tr>
161 <tr>
162 <td valign="top">omitted</td>
163 <td valign="top">true</td>
164 <td valign="top">basedir of calling project (the one whose build
165 file contains the &lt;ant&gt; task).</td>
166 </tr>
167 <tr>
168 <td valign="top">omitted</td>
169 <td valign="top">false</td>
170 <td valign="top">basedir attribute of the &lt;project&gt; element
171 of the new project</td>
172 </tr>
173</table>
174
175<h3>Examples</h3>
176<pre>
177 &lt;ant antfile=&quot;subproject/subbuild.xml&quot; dir=&quot;subproject&quot; target=&quot;compile&quot;/&gt;
178
179 &lt;ant dir=&quot;subproject&quot;/&gt;
180
181 &lt;ant antfile=&quot;subproject/property_based_subbuild.xml&quot;&gt;
182 &lt;property name=&quot;param1&quot; value=&quot;version 1.x&quot;/&gt;
183 &lt;property file=&quot;config/subproject/default.properties&quot;/&gt;
184 &lt;/ant&gt;
185
186 &lt;ant inheritAll=&quot;false&quot; antfile=&quot;subproject/subbuild.xml&quot;&gt;
187 &lt;property name=&quot;output.type&quot; value=&quot;html&quot;/&gt;
188 &lt;/ant&gt;
189</pre>
190
191<p>The build file of the calling project defines some
192<code>&lt;path&gt;</code> elements like this:</p>
193
194<pre>
195 &lt;path id="path1"&gt;
196 ...
197 &lt;/path&gt;
198 &lt;path id="path2"&gt;
199 ...
200 &lt;/path&gt;
201</pre>
202
203<p>and the called build file (<code>subbuild.xml</code>) also defines
204a <code>&lt;path&gt;</code> with the id <code>path1</code>, but
205<code>path2</code> is not defined:</p>
206
207<pre>
208 &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;true&quot;/&gt;
209</pre>
210
211<p>will not override <code>subbuild</code>'s definition of
212<code>path1</code>, but make the parent's definition of
213<code>path2</code> available in the subbuild.</p>
214
215<pre>
216 &lt;ant antfile=&quot;subbuild.xml&quot;/&gt;
217</pre>
218
219<p>as well as</p>
220
221<pre>
222 &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;/&gt;
223</pre>
224
225<p>will neither override <code>path1</code> nor copy
226<code>path2</code>.</p>
227
228<pre>
229 &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;&gt;
230 &lt;reference refid=&quot;path1&quot;/&gt;
231 &lt;/ant&gt;
232</pre>
233
234<p>will override <code>subbuild</code>'s definition of
235<code>path1</code>.</p>
236
237<pre>
238 &lt;ant antfile=&quot;subbuild.xml&quot; inheritrefs=&quot;false&quot;&gt;
239 &lt;reference refid=&quot;path1&quot; torefid=&quot;path2&quot;/&gt;
240 &lt;/ant&gt;
241</pre>
242
243<p>will copy the parent's definition of <code>path1</code> into the
244new project using the id <code>path2</code>.</p>
245
246<hr>
247<p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
248Reserved.</p>
249
250</body>
251</html>
Note: See TracBrowser for help on using the repository browser.