2003-07-09 16:24:38 +00:00
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2003-08-22 10:00:06 +00:00
|
|
|
<title>Import Task</title>
|
2004-04-16 22:43:27 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
2003-07-09 16:24:38 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2003-09-19 09:43:43 +00:00
|
|
|
<h2><a name="import">Import</a></h2>
|
|
|
|
<h3>Description</h3>
|
|
|
|
<p>
|
|
|
|
Imports another build file into the current project.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
On execution it will read another Ant file into
|
|
|
|
the same Project. This means that it basically works like the
|
|
|
|
<a href="http://ant.apache.org/faq.html#xml-entity-include">Entity
|
|
|
|
Includes as explained in the Ant FAQ</a>, as if the imported file was
|
|
|
|
contained in the importing file, minus the top <code><project></code>
|
|
|
|
tag.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
The import task may only be used as a top-level task. This means that
|
|
|
|
it may not be used in a target.
|
|
|
|
</p>
|
|
|
|
<p>
|
2003-07-09 16:24:38 +00:00
|
|
|
There are two further functional aspects that pertain to this task and
|
2003-09-19 09:43:43 +00:00
|
|
|
that are not possible with entity includes:
|
2003-07-09 16:24:38 +00:00
|
|
|
<ul>
|
|
|
|
<li>target overriding</li>
|
2003-09-19 09:43:43 +00:00
|
|
|
<li>special properties</li>
|
2003-07-09 16:24:38 +00:00
|
|
|
</ul>
|
2003-09-19 09:43:43 +00:00
|
|
|
</p>
|
2004-04-16 21:21:50 +00:00
|
|
|
<b>Target overriding</b><br />
|
|
|
|
<br />
|
|
|
|
If a target in the main file is also present in at least one of the
|
|
|
|
imported files, it takes precedence.<br />
|
|
|
|
<br />
|
2003-07-09 16:24:38 +00:00
|
|
|
So if I import for example a <i>docsbuild.xml</i> file named <b>builddocs</b>,
|
2004-04-16 21:21:50 +00:00
|
|
|
that contains a "<b>docs</b>" target, I can redefine it in my main
|
|
|
|
buildfile and that is the one that will be called. This makes it easy to
|
|
|
|
keep the same target name, so that the overriding target is still called
|
|
|
|
by any other targets--in either the main or imported buildfile(s)--for which
|
|
|
|
it is a dependency, with a different implementation. The original target is
|
|
|
|
made available by the name "<b>builddocs</b><b>.docs</b>".
|
|
|
|
This enables the new implementation to call the old target, thus
|
|
|
|
<i>enhancing</i> it with tasks called before or after it.<br />
|
|
|
|
<br />
|
|
|
|
<b>Special Properties</b><br />
|
|
|
|
<br />
|
|
|
|
Imported files are treated as they are present in the main
|
2003-07-09 16:24:38 +00:00
|
|
|
buildfile. This makes it easy to understand, but it makes it impossible
|
|
|
|
for them to reference files and resources relative to their path.
|
|
|
|
Because of this, for every imported file, Ant adds a property that
|
|
|
|
contains the path to the imported buildfile. With this path, the
|
|
|
|
imported buildfile can keep resources and be able to reference them
|
2004-04-16 21:21:50 +00:00
|
|
|
relative to its position.<br />
|
|
|
|
<br />
|
2003-07-09 16:24:38 +00:00
|
|
|
So if I import for example a <i>docsbuild.xml</i> file named <b>builddocs</b>,
|
|
|
|
I can get its path as <b>ant.file.builddocs</b>, similarly to the <b>ant.file</b>
|
2004-04-16 21:21:50 +00:00
|
|
|
property of the main buildfile.<br />
|
|
|
|
Note that "builddocs" is not the filename, but the name attribute
|
|
|
|
present in the imported project tag.<br />
|
|
|
|
<br />
|
2003-07-09 16:24:38 +00:00
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tbody>
|
|
|
|
<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>
|
2004-04-16 22:43:27 +00:00
|
|
|
<td valign="top">
|
|
|
|
file
|
2003-07-09 16:24:38 +00:00
|
|
|
</td>
|
2004-04-16 22:43:27 +00:00
|
|
|
<td valign="top">
|
2004-04-29 10:13:17 +00:00
|
|
|
The file to import. If this is a relative file name, the file name will be resolved
|
|
|
|
relative to the <i>importing</i> file. <b>Note</b>, this is unlike most other
|
|
|
|
ant file attributes, where relative files are resolved relative to ${basedir}.
|
2003-07-09 16:24:38 +00:00
|
|
|
</td>
|
|
|
|
<td valign="top" align="center">Yes</td>
|
|
|
|
</tr>
|
2003-10-16 17:04:01 +00:00
|
|
|
<tr>
|
2004-04-16 22:43:27 +00:00
|
|
|
<td valign="top">
|
|
|
|
optional
|
2003-10-16 17:04:01 +00:00
|
|
|
</td>
|
|
|
|
<td valign="top">
|
2004-04-29 10:13:17 +00:00
|
|
|
If true, do not stop the build if the file does not exist,
|
2004-04-16 22:43:27 +00:00
|
|
|
default is false.
|
2003-10-16 17:04:01 +00:00
|
|
|
</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
2003-07-09 16:24:38 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2004-04-16 21:21:50 +00:00
|
|
|
<h3><br />
|
2003-07-09 16:24:38 +00:00
|
|
|
</h3>
|
|
|
|
<h3>Examples</h3>
|
2004-04-16 21:21:50 +00:00
|
|
|
<pre> <import file="../common-targets.xml" /><br /></pre>
|
|
|
|
<br />
|
2003-07-09 16:24:38 +00:00
|
|
|
Imports targets from the common-targets.xml file that is in a parent
|
2004-04-16 21:21:50 +00:00
|
|
|
directory.<br />
|
|
|
|
<br />
|
|
|
|
<pre> <import file="${deploy-platform}.xml" /><br /></pre>
|
|
|
|
<br />
|
|
|
|
Imports the project defined by the property deploy-platform<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
2003-07-09 16:24:38 +00:00
|
|
|
<hr>
|
2004-04-16 22:48:18 +00:00
|
|
|
<p align="center">Copyright © 2003-2004 The Apache Software
|
2003-07-09 16:24:38 +00:00
|
|
|
Foundation. All rights
|
|
|
|
Reserved.</p>
|
|
|
|
</body>
|
|
|
|
</html>
|