Ant is similar to Make but is
portable to any platform that supports Java. See the
Jakarta Ant Project
for Ant downloads and documentation.
Example
Ant builds are governed by a build.xml file that serves much the
same purpose as make's Makefile.The following build.xml fragment shows how java+ fits into the Ant build
process. Change the taskdef classpath to where you installed
java+ and adjust the other option settings to match your build
environment. See Ant's documentation for full instructions.
<target name="build/java+.jar" depends="init">
<taskdef name="javaplus"
classpath="java+.jar">
classname="edu.virtualschool.javaplus.Ant"
</taskdef>
<javaplus
verbose="false"
force="true"
bundle="bndl"
srcDir="src"
binDir="build/bin"
dstDir="build/dst"
srcSuffix=".java"
dstSuffix=".java"
binSuffix=".properties"
skipDir="CVS"
skipSuffix=".bak"
/>
<javac
srcDir="build/dst"
binDir="build/bin"
classpath="${classpath}"
/>
<jar
jarfile="build/java+.jar"
manifest="manifests/GraphicalAdapter.txt">
<fileset dir="build/bin">
<exclude name="java+.jar" />
</fileset>
</jar>
</target>
This fragment preprocesses all source files, compiles the result,
and builds a jar file each time ant is run.
The taskdef statement registers AntAdapter class as an Ant
task. The java+ statement launches Java+ with the options explained in
the first section to generate files into dstDir and binDir as appropriate,
The javac statement compiles the dstDir contents and adds them to binDir.
The jar statement builds the combined binDir contents into a jar file.
Ant Options Reference
You convey your compilation process to java+ by specifying the
following parameters in Ant's build.xml file. All are optional if
the defaults (shown in parentheses) are acceptable:
- verbose="true" (false)
- Selects verbose output. The default is to only log errors.
- force="true" (false)
- Forces reprocessing of inputs even when outputs are up to
date. By default, up to date inputs are skipped (including non-java
files).
- project="projectDirectory" (.)
- Specifies the path to the project directory, by default, ".".
- bundle="bundleVariableName" (bndl)
- Enables the bundle option and specifies the bundle variable
name. This option redirects all Java+ strings into ResourceBundle
files, replacing them with bundleVariableName.getString() calls.
The default is to convert Java+ strings to ordinary Java strings.
- digraphs="fourCharacters" ({{}})
- Specifies the digraph characters that will delimit Java+
strings. The first and last pairs must be different.
- srcDir="sourceDirectory" (src)
dstDir="destinationDirectory" (dst)
binDir="binaryDirectory" (bin)
- Specifies the source (srcDir), destination (dstDir), and binary
(binDir) directories, all relative to the project directory.
The binary output directory (binDir) is used for resource bundle
files generated by the bundle option, and as the destination for
non-java input files (except those skipped by the skipDir/skipSuffix
options below). Output directories are created automatically as
required.
- srcSuffix="sourceSuffix" (.java)
dstSuffix="destionationSuffix" (.java)
binSuffix="binarySuffix" (.properties)
- Specifies the suffix for java+ source files (srcSuffix), the suffix
to be generated for java+ output files (i.e. javac/jikes input files),
and for java+ output files generated by the bundle option (resource
bundle files; i.e. binSuffix). "Binary" signifies the directory into which
the compiler will emit binary output files; it doesn't mean that other
files can't be stored there to be eventually conveyed to the jar file,
such as ascii resource files. If suffixes don't begin with a period ('.'),
one will be automatically prepended.
- skipDir="directoryName"
skipSuffix="skipSuffix"
- srcDir subdirectories named directoryName, and srcDir
file names ending in skipSuffix, will be silently skipped.
Both are cumulative and can be specified as many times
as required. By default only srcDir file or directory
names beginning with "." are skipped.