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