## AntLib

### Description

Defines and loads elements contained in an ANT library.

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.

Ant libraries are associated with ClassLoaders identified by the `loaderid` 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.

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 `useCurrentClassloader` 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.

Ant libraries define objects of several types:

1. Roles: 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.
2. Tasks: define elements that belong to the predefined role "task".
3. Data types: define elements that belong to the predefined role "datatype".
4. Other role elements: declare elements for other roles that have been previously defined.

### Parameters

Attribute | Description | Required
file | The jar-file of the library. | at least one of the two
library | The name of a library relative to ${ant.home}/antlib.
override | Replace any existing definition with the same name. ("true"/"false"). When "false" already defined tasks and datatytes take precedence over those in the library. Default is "false" when omitted. | No
useCurrentClassloader | Set to "true" 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 "false". | No
classpath | A classpath for extra libraries to pull in. | No
loaderid | 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. | No

### Parameters specified as nested elements

#### alias

Specifies the usage of a different name from that defined in the library descriptor. Applies only to element definitions (not role declarations).

Attribute | Description | Required
name | The name used in the library descriptor. | Yes
as | The alias to use in the project. | Yes

Specifies the usage of a different name from that defined in the library descriptor. This is used to deal with name clashes

#### classpath

A classpath of extra libraries to import to support this library.

#### classpathref

A reference to an existing classpath.

### Examples

      <antlib file="${build}/lib/mylib.jar"/>

loads the definitions from the library located at `${build}/lib/ant.jar`.

      <antlib library="optional.jar"/>

loads the definitions from the library `optional.jar` located at `${ant.home}/lib`.

      <antlib file="${build}/lib/mylib.jar">
        <alias name="echo" as="myecho"/>
      </antlib>

loads the definitions from the library located at `${build}/lib/ant.jar` but uses the name "`myecho`" for the "`echo`" task declared in the library.

Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.