Home

 

Global properties

Properties that will be referenced throughout the whole script file can be placed at the beginning of the Ant script. Here we define the property build.compiler that tells the javac command what compiler to use. We tell it to use the Eclipse compiler.

We also define the names for the source directory, the build directory, and the distribute directory. The source directory is where the Java source files reside. The build directory is where the class files end up, and the distribute directory is where the resulting JAR file is placed:

We define the source property as ".", which means that it is the same directory as the base directory specified in the project definition above.

The build and distribute directories will be created as c:\temp\build and c:\temp\RAD75Ant directories.

Properties can be set as shown here, but Ant can also read properties from standard Java properties files or use parameters passed as arguments on the command line:

<!-- set global properties for this build -->
<property name="build.compiler"
		value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<property name="source" value="."/>
<property name="build" value="c:\temp\build"/>
<property name="distribute"  value="c:\temp\RAD75Ant"/>
<property name="outFile" value="helloant"/>
ibm.com/redbooks