|
<xjc destdir="${build}" debug="on" verbose="on"
includes="${src}/**.java,${src}/**.xj"> <src location="${src}"/> <classpath refid="standard.classpath"/> </xjc> |
Before the <xjc> task can be used, it needs to be defined. This is normally done by including the provided antlib file. Below is an example build.xml target, <declarexjctask> that defines the <xjc> task:
|
<target name="declarexjctask">
<taskdef resource="com/ibm/xj/antlib.xml" onerror="fail" classpathref="standard.classpath"/> <property name="xjc.declared" value="true"/> </target> |
The antlib file is included in the distribution as part of the xj-ant.jar file, which needs to be in the classpath. Any target that uses the <xjc> task needs to depend on the <declarexjctask> target above. For convenience, upon successful declaration of the <xjc> task, the above target also defines the xjc.declared property, which the dependent targets could be made conditional upon:
|
<path id="standard.classpath">
<pathelement location="${build}"/> ... <fileset dir="${xjdir}/lib"> <include name="xj-ant.jar"/> <include name="xj-runtime.jar"/> <include name="xj-xpath.jar"/> </fileset> </path> ... <target name="compile" depends="init,declarexjctask" if="xjc.declared"> <xjc ...>...</xjc> ... </target> |
The XJ distribution includes a sample build.xml file in the samples directory.