In the directory java/alternative, you will
find a build item that has a hand-coded ant build file,
Abuild-ant.xml. When abuild encounters
this file, it invokes ant directly (Section 16.3, “The Abuild-ant.xml File”). If you examine the
Abuild-ant.xml in this directory, you will
notice that it defines a target all that
builds everything that would ordinarily be required by its
reverse dependencies. It also defines the standard targets
test, check, and
doc that are expected to be present for all
build items. In addition, it defines its own special target
run that runs the application. Notice that
the source path in the java element in this
file is ../src/java. Since abuild invokes
ant on this build file from inside the
abuild-java output directory, all references
to source paths must be prefixed by
“../”:
java/alternative/Abuild-ant.xml
<?xml version="1.0"?>
<project default="all">
<property file=".ab-dynamic-ant.properties"/>
<property name="jar-name" location="dist/alternative.jar"/>
<path id="classpath">
<pathelement path="${abuild.classpath}"/>
<pathelement path="${jar-name}"/>
</path>
<!-- Abuild expects the all target to build everything required -->
<!-- by items that depend upon this item. -->
<target name="all">
<mkdir dir="classes"/>
<mkdir dir="dist"/>
<javac source="1.5"
target="1.5"
destdir="classes"
classpathref="classpath"
includeantruntime="no">
<src path="../src/java"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-path"/>
</javac>
<jar destfile="${jar-name}">
<fileset dir="classes">
<include name="**/*.class"/>
</fileset>
</jar>
</target>
<!-- Abuild expects all build items to support these targets as -->
<!-- well. -->
<target name="check"/>
<target name="test"/>
<target name="doc"/>
<target name="run" depends="all">
<java classname="com.example.alternative.Alternative"
fork="true"
classpathref="classpath"/>
</target>
</project>
Also observe that this build file loads the
.ab-dynamic-ant.properties so that it can
still benefit from classpath information as determined by the
interfaces of its dependencies. All
Abuild-ant.xml files should do this. This
build item uses the property abuild.classpath,
which comes from that file. For a list of properties that will
be defined in .ab-dynamic-ant.properties,
see Section 14.5, “Predefined Abuild.interface Variables”.
At this time, it is uncertain what abuild's final Java support
will look like, but the use of
Abuild-ant.xml is not recommended unless
there is no other option.