# Ant User Manual

## AntJar

### Description

An extension of the Jar task with special treatment for the library descriptor file that should end up in the `META-INF` directory of the Ant Archive.

Descriptors must follow the following rules, although there is no fix DTD for them:

    <!-- Root element for the Antlib descriptor.                 -->
    <!ELEMENT antlib (role | rolename)* >

    <!-- Declaration of roles contained in the library.          -->
    <!ELEMENT role EMPTY>
    <!ATTLIST role
              name     CDATA #REQUIRED
              class    CDATA #REQUIRED
              proxy    CDATA #IMPLIED
    >

    <!-- Declaration of datatypes contained in the library       -->
    <!ELEMENT rolename EMPTY>
    <!ATTLIST rolename
              name     CDATA #REQUIRED
              class    CDATA #REQUIRED
    >

There are two predefined roles: task and datatype.

#### Role definition

The name of the role. This name is used when specifying elements for this role.

The class defining a role must be an interface containing a unique void method with only one argument whose type is the that of elements declared on the role.

The proxy defined in a role specifies a class that can be used to bridge between the type expected by the role and the type of elements declared for that role.

#### Element definition

Any element whose name is that of a role declares an element for that role.

The name defined the name of the element to use in the buildfile to specify the element being declared.

The class the class defining the element.

### Parameters

Attribute | Description | Required
antxml | The library descriptor to use (META-INF/antlib.xml). | Yes
Others... | All attributes inherited form the Jar task. |

### Nested elements

See the nested elements of the Jar task.

### Examples

      <antjar file="${dist}/lib/app.jar"
           antxml="${src}/applib.xml" basedir="${build}/classes"/>

jars all files in the `${build}/classes` directory into a file called `app.jar` in the `${dist}/lib` directory and sets the content of `${src}/applib.xml` as the library descriptor in `META-INF/antlib.xml`.

Here is a sample `META-INF/antlib.xml`:

    <?xml version="1.0" encoding="UTF8" ?>

    <antlib version="1.0" >
      <task name="case" class="org.apache.ant.contrib.Case" />
    </antlib>

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