Developing Web Applications With Ant by Richard Hightower - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Defining the properties lib and outputdir.

A property is defined as follows:
<property name="lib" value="../lib"/>
A property can be used inside another string literal as shown here: <fileset dir="${lib}">

A file set is used to define a set of files. It allows you to group files based on patterns using one or more include subelements, as shown in Listing 20.2. A file set is defined as follows:

 

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

A path allows you to define such things as classpaths (for compiling Java source and other tasks that need classpaths). A path consists of pathelements, which is a semicolon-delimited list of subdirectories or JAR files and file sets. Listing 20.2 uses the file set to add all the JAR files in the lib directory to the classpath defined with the ID myclasspath. Later in Listing 20.2 myclasspath is used by the javac task.

A path is defined as follows:

<path id=" myclasspath">
<pathelement path=".;${lib}/log4j.jar"/>
<fileset dir="${lib}">

<include name="**/*.jar"/>
</fileset>
</path>

 

A path can be used by a task using the classpath subelement:

<javac srcdir="./src" destdir="${ outputdir}/classes" > <classpath refid="myclasspath"/>
</javac>