[14982] | 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 |
|
---|
| 9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 10 |
|
---|
| 11 | Unless required by applicable law or agreed to in writing, software
|
---|
| 12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 14 | See the License for the specific language governing permissions and
|
---|
| 15 | limitations under the License.
|
---|
| 16 | -->
|
---|
| 17 | <html>
|
---|
| 18 |
|
---|
| 19 | <head>
|
---|
| 20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
| 21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
| 22 | <title>Ant Task</title>
|
---|
| 23 | </head>
|
---|
| 24 |
|
---|
| 25 | <body>
|
---|
| 26 |
|
---|
| 27 | <h2><a name="ant">Ant</a></h2>
|
---|
| 28 | <h3>Description</h3>
|
---|
| 29 |
|
---|
| 30 | <p>Runs Ant on a supplied buildfile. This can be used to build
|
---|
| 31 | subprojects. <strong>This task must not be used outside of a
|
---|
| 32 | <code>target</code> if it invokes the same build file it is part
|
---|
| 33 | of.</strong></p>
|
---|
| 34 |
|
---|
| 35 | <p>When the <i>antfile</i> attribute is omitted, the file "build.xml"
|
---|
| 36 | in the supplied directory (<i>dir</i> attribute) is used.</p>
|
---|
| 37 | <p>If no target attribute is supplied, the default target of the new project is
|
---|
| 38 | used.</p>
|
---|
| 39 | <p>By default, all of the properties of the current project will be
|
---|
| 40 | available in the new project. Alternatively, you can set the
|
---|
| 41 | <i>inheritAll</i> attribute to <code>false</code> and only
|
---|
| 42 | "user" properties (i.e., those passed on the command-line)
|
---|
| 43 | will be passed to the new project. In either case, the set of
|
---|
| 44 | properties passed to the new project will override the properties that
|
---|
| 45 | are set in the new project (See also the <a
|
---|
| 46 | href="property.html">property task</a>).</p>
|
---|
| 47 |
|
---|
| 48 | <p>You can also set properties in the new project from the old project
|
---|
| 49 | by using nested property tags. These properties are always passed
|
---|
| 50 | to the new project and any project created in that project
|
---|
| 51 | regardless of the setting of <i>inheritAll</i>. This allows you to
|
---|
| 52 | parameterize your subprojects. Properties defined on the command line
|
---|
| 53 | cannot be overridden by nested <code><property></code> elements.</p>
|
---|
| 54 |
|
---|
| 55 | <p>References to data types can also be passed to the new project, but
|
---|
| 56 | by default they are not. If you set the inheritrefs attribute to
|
---|
| 57 | true, all references will be copied, but they will not override
|
---|
| 58 | references defined in the new project.</p>
|
---|
| 59 |
|
---|
| 60 | <p>Nested <a href="#reference"><i><code><reference></code></i></a> elements
|
---|
| 61 | can also be used to copy references from the calling project to the
|
---|
| 62 | new project, optionally under a different id. References taken from
|
---|
| 63 | nested elements will override existing references that have been
|
---|
| 64 | defined outside of targets in the new project - but not those defined
|
---|
| 65 | inside of targets.</p>
|
---|
| 66 |
|
---|
| 67 | <h3>Parameters</h3>
|
---|
| 68 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
| 69 | <tr>
|
---|
| 70 | <td valign="top"><b>Attribute</b></td>
|
---|
| 71 | <td valign="top"><b>Description</b></td>
|
---|
| 72 | <td align="center" valign="top"><b>Required</b></td>
|
---|
| 73 | </tr>
|
---|
| 74 | <tr>
|
---|
| 75 | <td valign="top">antfile</td>
|
---|
| 76 | <td valign="top">the buildfile to use. Defaults to
|
---|
| 77 | "build.xml". This file is expected to be a filename
|
---|
| 78 | relative to the dir attribute given.</td>
|
---|
| 79 | <td valign="top" align="center">No</td>
|
---|
| 80 | </tr>
|
---|
| 81 | <tr>
|
---|
| 82 | <td valign="top">dir</td>
|
---|
| 83 | <td valign="top">the directory to use as a basedir for the new Ant project.
|
---|
| 84 | Defaults to the current project's basedir, unless
|
---|
| 85 | inheritall has been set to false, in which case it doesn't
|
---|
| 86 | have a default value. This will override the basedir
|
---|
| 87 | setting of the called project.</td>
|
---|
| 88 | <td valign="top" align="center">No</td>
|
---|
| 89 | </tr>
|
---|
| 90 | <tr>
|
---|
| 91 | <td valign="top">target</td>
|
---|
| 92 | <td valign="top">the target of the new Ant project that should be executed.
|
---|
| 93 | Defaults to the new project's default target.</td>
|
---|
| 94 | <td valign="top" align="center">No</td>
|
---|
| 95 | </tr>
|
---|
| 96 | <tr>
|
---|
| 97 | <td valign="top">output</td>
|
---|
| 98 | <td valign="top">Filename to write the ant output to. This is
|
---|
| 99 | relative to the value of the dir attribute if it has been set or
|
---|
| 100 | to the base directory of the current project otherwise.
|
---|
| 101 | </td>
|
---|
| 102 | <td align="center" valign="top">No</td>
|
---|
| 103 | </tr>
|
---|
| 104 | <tr>
|
---|
| 105 | <td valign="top">inheritAll</td>
|
---|
| 106 | <td valign="top">If <code>true</code>, pass all properties to the
|
---|
| 107 | new Ant project. Defaults to <code>true</code>.</td>
|
---|
| 108 | <td align="center" valign="top">No</td>
|
---|
| 109 | </tr>
|
---|
| 110 | <tr>
|
---|
| 111 | <td valign="top">inheritRefs</td>
|
---|
| 112 | <td valign="top">If <code>true</code>, pass all references to the
|
---|
| 113 | new Ant project. Defaults to <code>false</code>.</td>
|
---|
| 114 | <td align="center" valign="top">No</td>
|
---|
| 115 | </tr>
|
---|
| 116 | </table>
|
---|
| 117 |
|
---|
| 118 | <h3>Parameters specified as nested elements</h3>
|
---|
| 119 |
|
---|
| 120 | <h4>property</h4>
|
---|
| 121 | <p>See the description of the <a href="property.html">property
|
---|
| 122 | task</a>. <br>
|
---|
| 123 | These properties become equivalent to properties you define on
|
---|
| 124 | the command line. These are special properties and they will always get passed
|
---|
| 125 | down, even through additional <code><*ant*></code> tasks with inheritall set to
|
---|
| 126 | false (see above). <br>
|
---|
| 127 | Note that the <code>refid</code> attribute points to a
|
---|
| 128 | reference in the calling project, not in the new one.</p>
|
---|
| 129 |
|
---|
| 130 | <h4><a name="reference">reference</a></h4>
|
---|
| 131 | <p>Used to choose references that shall be copied into the new project,
|
---|
| 132 | optionally changing their id.</p>
|
---|
| 133 |
|
---|
| 134 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
| 135 | <tr>
|
---|
| 136 | <td valign="top"><b>Attribute</b></td>
|
---|
| 137 | <td valign="top"><b>Description</b></td>
|
---|
| 138 | <td align="center" valign="top"><b>Required</b></td>
|
---|
| 139 | </tr>
|
---|
| 140 | <tr>
|
---|
| 141 | <td valign="top">refid</td>
|
---|
| 142 | <td valign="top">The id of the reference in the calling project.</td>
|
---|
| 143 | <td valign="top" align="center">Yes</td>
|
---|
| 144 | </tr>
|
---|
| 145 | <tr>
|
---|
| 146 | <td valign="top">torefid</td>
|
---|
| 147 | <td valign="top">The id of the reference in the new project.</td>
|
---|
| 148 | <td valign="top" align="center">No, defaults to the value of refid.</td>
|
---|
| 149 | </tr>
|
---|
| 150 | </table>
|
---|
| 151 |
|
---|
| 152 | <h4>propertyset</h4>
|
---|
| 153 |
|
---|
| 154 | <p>You can specify a set of properties to be copied into the new
|
---|
| 155 | project with <a
|
---|
| 156 | href="../CoreTypes/propertyset.html">propertyset</a>s.</p>
|
---|
| 157 |
|
---|
| 158 | <p><em>since Ant 1.6</em>.</p>
|
---|
| 159 |
|
---|
| 160 | <h4>target</h4>
|
---|
| 161 |
|
---|
| 162 | <p>You can specify multiple targets using nested <code><target></code> elements
|
---|
| 163 | instead of using the target attribute. These will be executed as if
|
---|
| 164 | Ant had been invoked with a single target whose dependencies are the
|
---|
| 165 | targets so specified, in the order specified.</p>
|
---|
| 166 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
| 167 | <tr>
|
---|
| 168 | <td valign="top"><b>Attribute</b></td>
|
---|
| 169 | <td valign="top"><b>Description</b></td>
|
---|
| 170 | <td align="center" valign="top"><b>Required</b></td>
|
---|
| 171 | </tr>
|
---|
| 172 | <tr>
|
---|
| 173 | <td valign="top">name</td>
|
---|
| 174 | <td valign="top">The name of the called target.</td>
|
---|
| 175 | <td valign="top" align="center">Yes</td>
|
---|
| 176 | </tr>
|
---|
| 177 | </table>
|
---|
| 178 | <p><em>since Ant 1.6.3</em>.</p>
|
---|
| 179 |
|
---|
| 180 | <h3>Basedir of the new project</h3>
|
---|
| 181 |
|
---|
| 182 | <p>The basedir value of the new project is affected by the two
|
---|
| 183 | attributes dir and inheritall, see the following table for
|
---|
| 184 | details:</p>
|
---|
| 185 |
|
---|
| 186 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
| 187 | <tr>
|
---|
| 188 | <td valign="top"><b>dir attribute</b></td>
|
---|
| 189 | <td valign="top"><b>inheritAll attribute</b></td>
|
---|
| 190 | <td valign="top"><b>new project's basedir</b></td>
|
---|
| 191 | </tr>
|
---|
| 192 | <tr>
|
---|
| 193 | <td valign="top">value provided</td>
|
---|
| 194 | <td valign="top">true</td>
|
---|
| 195 | <td valign="top">value of dir attribute</td>
|
---|
| 196 | </tr>
|
---|
| 197 | <tr>
|
---|
| 198 | <td valign="top">value provided</td>
|
---|
| 199 | <td valign="top">false</td>
|
---|
| 200 | <td valign="top">value of dir attribute</td>
|
---|
| 201 | </tr>
|
---|
| 202 | <tr>
|
---|
| 203 | <td valign="top">omitted</td>
|
---|
| 204 | <td valign="top">true</td>
|
---|
| 205 | <td valign="top">basedir of calling project (the one whose build
|
---|
| 206 | file contains the <code><ant></code> task).</td>
|
---|
| 207 | </tr>
|
---|
| 208 | <tr>
|
---|
| 209 | <td valign="top">omitted</td>
|
---|
| 210 | <td valign="top">false</td>
|
---|
| 211 | <td valign="top">basedir attribute of the <code><project></code> element
|
---|
| 212 | of the new project</td>
|
---|
| 213 | </tr>
|
---|
| 214 | </table>
|
---|
| 215 |
|
---|
| 216 | <h3>Examples</h3>
|
---|
| 217 | <blockquote><pre>
|
---|
| 218 | <ant antfile="subproject/subbuild.xml" target="compile"/>
|
---|
| 219 |
|
---|
| 220 | <ant dir="subproject"/>
|
---|
| 221 |
|
---|
| 222 | <ant antfile="subproject/property_based_subbuild.xml">
|
---|
| 223 | <property name="param1" value="version 1.x"/>
|
---|
| 224 | <property file="config/subproject/default.properties"/>
|
---|
| 225 | </ant>
|
---|
| 226 |
|
---|
| 227 | <ant inheritAll="false" antfile="subproject/subbuild.xml">
|
---|
| 228 | <property name="output.type" value="html"/>
|
---|
| 229 | </ant>
|
---|
| 230 | </pre></blockquote>
|
---|
| 231 |
|
---|
| 232 | <p>These lines invoke the same build file:</p>
|
---|
| 233 | <blockquote><pre>
|
---|
| 234 | <ant antfile="sub1/sub2/build.xml" />
|
---|
| 235 | <ant antfile="sub2/build.xml" dir="sub1" />
|
---|
| 236 | <ant antfile="build.xml" dir="sub1/sub2" />
|
---|
| 237 | </pre></blockquote>
|
---|
| 238 |
|
---|
| 239 | <p>The build file of the calling project defines some
|
---|
| 240 | <code><path></code> elements like this:</p>
|
---|
| 241 |
|
---|
| 242 | <blockquote><pre>
|
---|
| 243 | <path id="path1">
|
---|
| 244 | ...
|
---|
| 245 | </path>
|
---|
| 246 | <path id="path2">
|
---|
| 247 | ...
|
---|
| 248 | </path>
|
---|
| 249 | </pre></blockquote>
|
---|
| 250 |
|
---|
| 251 | <p>and the called build file (<code>subbuild.xml</code>) also defines
|
---|
| 252 | a <code><path></code> with the id <code>path1</code>, but
|
---|
| 253 | <code>path2</code> is not defined:</p>
|
---|
| 254 |
|
---|
| 255 | <blockquote><pre>
|
---|
| 256 | <ant antfile="subbuild.xml" inheritrefs="true"/>
|
---|
| 257 | </pre></blockquote>
|
---|
| 258 |
|
---|
| 259 | <p>will not override <code>subbuild</code>'s definition of
|
---|
| 260 | <code>path1</code>, but make the parent's definition of
|
---|
| 261 | <code>path2</code> available in the subbuild.</p>
|
---|
| 262 |
|
---|
| 263 | <blockquote><pre>
|
---|
| 264 | <ant antfile="subbuild.xml"/>
|
---|
| 265 | </pre></blockquote>
|
---|
| 266 |
|
---|
| 267 | <p>as well as</p>
|
---|
| 268 |
|
---|
| 269 | <blockquote><pre>
|
---|
| 270 | <ant antfile="subbuild.xml" inheritrefs="false"/>
|
---|
| 271 | </pre></blockquote>
|
---|
| 272 |
|
---|
| 273 | <p>will neither override <code>path1</code> nor copy
|
---|
| 274 | <code>path2</code>.</p>
|
---|
| 275 |
|
---|
| 276 | <blockquote><pre>
|
---|
| 277 | <ant antfile="subbuild.xml" inheritrefs="false">
|
---|
| 278 | <reference refid="path1"/>
|
---|
| 279 | </ant>
|
---|
| 280 | </pre></blockquote>
|
---|
| 281 |
|
---|
| 282 | <p>will override <code>subbuild</code>'s definition of
|
---|
| 283 | <code>path1</code>.</p>
|
---|
| 284 |
|
---|
| 285 | <blockquote><pre>
|
---|
| 286 | <ant antfile="subbuild.xml" inheritrefs="false">
|
---|
| 287 | <reference refid="path1" torefid="path2"/>
|
---|
| 288 | </ant>
|
---|
| 289 | </pre></blockquote>
|
---|
| 290 |
|
---|
| 291 | <p>will copy the parent's definition of <code>path1</code> into the
|
---|
| 292 | new project using the id <code>path2</code>.</p>
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | </body>
|
---|
| 297 | </html>
|
---|