| Table of Contents |
Ant also provides optional data types, such as:
ClassFileSet
Extension
ExtensionSet
The ClassFileSet data type is a special set of files, which includes all the class files on which the root class depends. ClassFileSet is typically a FileSet data type, which enlists all classes that depend on a set of root classes. You need to include the root class in the <classfileset> tag because it is the starting point in a dependency search. ClassFileSet extends FileSet. The nested FileSet attribute provides the domain for the dependency search. In addition to the standard FileSet data type, ClassFileSet contains an attribute, rootclass. This attribute is a single-root class name. ClassFileSet supports two nested elements:
The root element
The rootfileset element
The root element provides multiple root classes. This element provides the classname attribute. This attribute is useful for creating jar files that contain all the files required for an application. You provide the root of the directory structure in the classname attribute. The root element is mandatory. The following code shows how to use root with the classname attribute:
<classfileset id="reqdClasses" dir="${classes.dir}">
<root classname="org.apache.tools.ant.Project" />
</classfileset>
The above code uses root with the classname attribute for the org.apache.tools.ant.Project class. The code includes all the files on which the org.apache.tools.ant.Project class depends.
The rootfileset element adds a set of root classes from a FileSet data type. Entries in FileSet should be Java classes. Listing 2-32 shows how to list files using the rootfileset element:
The above listing shows how to select all the .class files whose names start with test in the org/apache/tools/ant1.2 package.
The Extension data type works on extensions of Optional Package information. Optional Package is a set of Application Programmers Interfaces (APIs) defined in Optional Package Versioning in the documentation bundle for the Java2 Standard Edition package. Extension is similar to a utility that represents optional packages described in the manifest of a Jar file. The mandatory attribute of Extension is extensionName, which defines the name of the extension. The mandatory attributes of Extension are:
specificationVersion: Defines the version of the extension specification.
specificationVendor: Defines the specification vendor.
implementationVendor: Defines the implementation vendor.
implementationVendorId: Defines the implementation vendor ID.
implementationURL: Defines the URL form where you will retrieve the extension.
Listing 2-33 shows an extension object:
<extension id="E1" extensionName="ExtNo1" specificationVersion="1.0" specificationVendor="Peter James" implementationVendorID="vv" implementationVendor="Apache" implementationVersion="2.0" implementationURL="http://somewhere.com/myExt.jar"/>
The above listing shows a full extension object and defines all the attributes of the extension object.
The ExtensionSet data type represents a set of extensions. This data type works on the extensions of Optional Package specifications. This data type can contain multiple extensions.
ExtensionSet contains three elements:
extension: Defines the extension that the extension set adds to itself.
fileset: Defines the list of files contained in the extension set.
libfileset: Defines the attributes of the FileSet data type that modifies extension information.
Listing 2-34 shows an example of the ExtensionSet data type:
<extension id="E1" extensionName=" ExtNo1" specificationVersion="1.0" specificationVendor=" Peter James " implementationVendorID="vv" implementationVendor="Apache" implementationVersion="2.0" implementationURL="http://somewhere.com/myExt.jar"/> <libfileset id="lfs" includeUrl="true" includeImpl="false" dir="tools/lib"> <include name="*.jar"/> </libfileset> <extensionSet id="extset1"> <libfileset dir="lib"> <include name="*.jar"/> </libfileset> <libfileset refid="lfs"/> <extension refid="e1"/> </extensionSet>
The above listing shows ExtensionSet with all its attributes.
| Table of Contents |