blob: ee6a4a1305626cdb7f80ce212243a7fa1f8b4bd9 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Ant User Manual</title>
</head>
<body>
<h2><a name="antjar">AntJar</a></h2>
<h3>Description</h3>
<p>An extension of the <a href="jar.html">Jar</a> task with special
treatment for the library descriptor file that should end up in the
<code>META-INF</code> directory of the Ant Archive.</p>
<p>
Descriptors must follow the following rules, although there is no fix DTD
for them:
<pre>
&lt;!-- Root element for the Antlib descriptor. --&gt;
&lt;!ELEMENT antlib (role | <i>rolename</i>)* &gt;
&lt;!-- Declaration of roles contained in the library. --&gt;
&lt;!ELEMENT role EMPTY&gt;
&lt;!ATTLIST role
name CDATA #REQUIRED
class CDATA #REQUIRED
proxy CDATA #IMPLIED
&gt;
&lt;!-- Declaration of datatypes contained in the library --&gt;
&lt;!ELEMENT <i>rolename</i> EMPTY&gt;
&lt;!ATTLIST <i>rolename</i>
name CDATA #REQUIRED
class CDATA #REQUIRED
&gt;
</pre>
There are two predefined roles: <i><b>task</b></i> and <i><b>datatype</b></i>.
<p>
<h4>Role definition</h4>
The <b>name</b> of the role. This name is used when specifying
elements for this role.
<p>
The <b>class</b> 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.
<p>
The <b>proxy</b> 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.
<h4>Element definition</h4>
Any element whose name is that of a role declares an element for that role.
<p>
The <b>name</b> defined the name of the element to use in the buildfile
to specify the element being declared.
<p>
The <b>class</b> the class defining the element.
<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">antxml</td>
<td valign="top">The library descriptor to use (META-INF/antlib.xml).</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top"><b>Others...</b></td>
<td valign="top">All attributes inherited form the
<a href="jar.html">Jar task</a>.</td>
<td valign="top" align="center"> </td>
</tr>
</table>
<h3>Nested elements</h3>
See the nested elements of the <a href="jar.html">Jar task</a>.
<h3>Examples</h3>
<pre> &lt;antjar file=&quot;${dist}/lib/app.jar&quot;
antxml=&quot;${src}/applib.xml&quot; basedir=&quot;${build}/classes&quot;/&gt;</pre>
<p>jars all files in the <code>${build}/classes</code> directory into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory and
sets the content of <code>${src}/applib.xml</code> as the library descriptor
in <code>META-INF/antlib.xml</code>.</p>
<p>Here is a sample <code>META-INF/antlib.xml</code>:</p>
<pre>
&lt;?xml version="1.0" encoding="UTF8" ?&gt;
&lt;antlib version="1.0" &gt;
&lt;task name="case" class="org.apache.ant.contrib.Case" /&gt;
&lt;/antlib&gt;
</pre>
<hr>
<p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
Reserved.</p>
</body>
</html>