blob: ca4c3183655983498c9f46f702f996f420440c10 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Ant User Manual</title>
</head>
<body>
<h2><a name="antlib">AntLib</a></h2>
<h3>Description</h3>
<p>Defines and loads elements contained in an ANT library.</p>
<p>It also allows the aliasing of the names being defined in order to avoid
collisions and provides means to override definitions with the ones defined
in the library.</p>
Ant libraries are associated with ClassLoaders identified by the
<tt>loaderid</tt> attribute. If no loader is specified a default loader
will be used. Ant libraries specifying the same loader are loaded by the
same ClassLoader as long as the libraries are defined on the same project.
Classloaders with the same ID in a subproject have the corresponding
classloader in the parent project as their parent classloader.
<p>
Ant libraries can be loaded in the current classloader,
which is more efficient,
but requires the tasks to be in the path already (such as in the ant lib
directory) - set <tt>useCurrentClassloader</tt> to true to enable this.
It is also possible to add more libraries to the path, such as any
libraries the task is dependent on.
<p>
Ant libraries define objects of several types:
<ol>
<li> <b>Roles</b>: Define an interface to be implemented by elements
(usually tasks) that accept subelements of the specified role.
Roles may also define a proxy class which may be applied to an element
in order to make it compatible with the role.
</li>
<li> <b>Tasks</b>: define elements that belong to the predefined
role "task".
<li> <b>Data types</b>: define elements that belong to the predefined role
"datatype".
<li> <b>Other role elements</b>: declare elements for other roles that
have been previously defined.
</ol>
<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">file</td>
<td valign="top">The jar-file of the library.</td>
<td align="center" valign="middle" rowspan="2">at least one of the two</td>
</tr>
<tr>
<td valign="top">library</td>
<td valign="top">The name of a library relative to ${ant.home}/antlib.</td>
</tr>
<tr>
<td valign="top">override</td>
<td valign="top">Replace any existing definition with the same name.
(&quot;true&quot;/&quot;false&quot;).
When &quot;false&quot; already defined tasks
and datatytes take precedence over those in the library.
Default is &quot;false&quot; when omitted.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">useCurrentClassloader</td>
<td valign="top">Set to &quot;true&quot; to avoid using a separate
ClassLoader for the tasks in the library. Using this option requires
that the library jar is already accessible by the ClassLoader of
the project. Default is &quot;false&quot;.
</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">classpath</td>
<td valign="top">A
<a href="../using.html#path">classpath</a>
for extra libraries to pull in.
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">loaderid</td>
<td valign="top">The ID of the ClassLoader to use to load the classes
defined in this library. If omitted a default per project ClassLoader
will be used.
</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3><a name="nested">Parameters specified as nested elements</a></h3>
<h4>alias</h4>
<p>Specifies the usage of a different name from that defined in the library
descriptor. Applies only to element definitions (not role declarations).</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 used in the library descriptor.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">as</td>
<td valign="top">The alias to use in the project.</td>
<td valign="top" align="center">Yes</td>
</tr>
</table>
<p>Specifies the usage of a different name from that defined in the library
descriptor. This is used to deal with name clashes </p>
<h4>classpath</h4>
A classpath of extra libraries to import to support this library.
<h4>classpathref</h4>
A reference to an existing classpath.
<h3>Examples</h3>
<pre> &lt;antlib file=&quot;${build}/lib/mylib.jar&quot;/&gt;</pre>
<p>loads the definitions from the library located at
<code>${build}/lib/ant.jar</code>.</p>
<pre> &lt;antlib library=&quot;optional.jar&quot;/&gt;</pre>
<p>loads the definitions from the library <code>optional.jar</code>
located at <code>${ant.home}/lib</code>.</p>
<pre> &lt;antlib file=&quot;${build}/lib/mylib.jar&quot&gt;
&lt;alias name=&quot;echo&quot; as=&quot;myecho&quot;/&gt;
&lt;/antlib&gt;
</pre>
<p>loads the definitions from the library located at
<code>${build}/lib/ant.jar</code> but uses the name
&quot;<code>myecho</code>&quot; for the &quot;<code>echo</code>&quot; task
declared in the library.</p>
<hr><p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
Reserved.</p>
</body>
</html>