Skip to content
UoL CS Notes

Ant Filesets and Path

COMP285 Lectures

Creating Filesets

Filesets are a group of files represented like so:

<fileset dir="src"
	includes="**/*.java"
	id="source.fileset"/>
  • dir - Mandatory attribute to denote a root directory for the fileset.
  • includes - Which files from this directory to include.
  • id - A reference which can be used to call the fileset.

We can also use the following syntax:

<fileset dir="lib">
	<include name="*.jar"/>
</fileset>

exclude can also be used to remove files. By default all the files in the dir are included.

Some patterns are excluded by default you can view them at https://ant.apache.org/manual/dirtasks.html#defaultexcludes and disable this functionality by using:

<fileset dir"..." defaultexcludes="no"/>

Using Filesets

We can use filesets like so:

<copy todir="backup">
	<fileset refid="source.fileset"/>
</copy>

javac Task

We can refer to the javac task manual to see how we can use compiler flags: https://ant.apache.org/manual/Tasks/javac.html

We can combine this with our knowledge of Ant properties to make the following build task:

<path id="compile.classpath">
	<pathelement location="${lucine.jar}"/>
	<pathelement location="${jtidy.jar}"/>
</path>
<javac destdir="${build.classes.dir}"
	debug="${build.debug}"
	srcdir="$(src.dir)"
	includeAntRuntime="no"
>
	<include name="**.*.java"/>
	<classpath refid="compile.classpath"/>
</javac>

This can make large build files with lots of repetition easy to change.

path

We can use path in place of location using the following syntax:

<classpath path="bulid/classes:lib/some.jar"/>
<classpath>
	<pathelement path="bulid/classes:lib/some.jar"/>
</classpath>

Both ; and : are allowed as a separator.