ant/docs/manual/CoreTasks/antlib.html
2001-11-12 07:46:27 +00:00

118 lines
4.0 KiB
HTML

<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 any tasks and datatypes 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 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.
<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}/lib.</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>
</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.</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>
<h4>classpath</h4>
A classpath of extra libraries to import to support this task.
<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>