A classfileset is a specialised type of fileset which, given a set of "root" classes, will include all of the class files upon which the root classes depend. This is typically used to create a jar with all of the required classes for a particular application.
classfilesets are typically used by reference. They are declared with an "id" value and this is then used as a reference where a normal fileset is expected.
This type requires the jakarta-BCEL
library.
The class fileset support the following attributes in addition to those supported by the standard fileset:
Attribute | Description | Required |
rootclass | A single root class name | No |
When more than one root class is required, multiple nested <root>
elements
may be used
Attribute | Description | Required |
classname | The fully qualified name of the root class | Yes |
A root fileset is used to add a set of root classes from a fileset. In this case the entries in
the fileset are expected to be Java class files. The name of the Java class is determined by the
relative location of the classfile in the fileset. So, the file
org/apache/tools/ant/Project.class
corresponds to the Java class
org.apache.tools.ant.Project
.
<classfileset id="reqdClasses" dir="${classes.dir}"> <root classname="org.apache.tools.ant.Project"/> </classfileset>
This example creates a fileset containing all the class files upon which the
org.apache.tools.ant.Project
class depends. This fileset could
then be used to create a jar.
<jar destfile="minimal.jar"> <fileset refid="reqdClasses"/> </jar>
<classfileset id="reqdClasses" dir="${classes.dir}"> <rootfileset dir="${classes.dir}" includes="org/apache/tools/ant/Project*.class"/> </classfileset>
This example constructs the classfileset using all the class with names starting with Project in the org.apache.tools.ant package