Developing with JAXB and Ant, Part 1
Subject:   Or, using an old trick ...
Date:   2002-03-14 10:10:52
From:   hlship
I used an old Makefile trick, where you create a temporary file as a stand-in for anything generated by a rule:

<?xml version="1.0"?>
<!-- $Id: build.xml,v 1.1 2002/02/24 06:33:08 hship Exp $ -->
<project name="Sabertooth Framework" default="compile">

<property name="root.dir" value="../.."/>

<!-- Get the build properties, so we know where JAXB is located. -->

<property file="${root.dir}/config/"/>

<!-- Local directories -->

<property name="lib.dir" value="${root.dir}/lib"/>
<property name="lib.ext.dir" value="${lib.dir}/ext"/>
<property name="classes.dir" value="classes"/>
<property name="src.dir" value="src"/>
<property name="derived-src.dir" value="derived-src"/>
<property name="dtd.dir" value="dtd"/>
<property name="build.dir" value=".build"/>

<!-- Used to control when to re-run JAXP. Ideally, we'd compare against
the derived source files, but haven't figured out that trick
yet. -->

<property name="dtd.stamp.file" value="${build.dir}/dtd_stamp_file"/>

<property name="jaxb.lib.dir" value="${jaxb.dir}/lib"/>

<path id="compile.classpath">
<pathelement location="${jaxb.lib.dir}/jaxb-rt-1.0-ea.jar"/>
<pathelement location="${lib.ext.dir}/log4j-core.jar"/>
<pathelement location="${lib.ext.dir}/com.primix.tapestry.jar"/>

<target name="clean">
<delete dir="${classes.dir}" quiet="true"/>
<delete dir="${derived-src.dir}" quiet="true"/>
<delete dir="${build.dir}" quiet="true"/>

description="Run JAXB compiler to generate derived sources.">
<mkdir dir="${derived-src.dir}"/>

<arg line="${dtd.dir}/Sabertooth_JDBC_1_0.dtd ${dtd.dir}/Sabertooth_JDBC.xjs -d ${derived-src.dir}"/>

<mkdir dir="${build.dir}"/>
<touch file="${dtd.stamp.file}"/>

<target name="check-jaxb" description="Checks to see if JAXB must be run again.">
<uptodate property="jaxb.not-required" targetfile="${dtd.stamp.file}">
<srcfiles dir="${dtd.dir}">
<include name="**/*.dtd"/>
<include name="**/*.xjs"/>

<!-- Run the jaxb target, which will be a no-op if jaxb.not-required is set. -->

<antcall target="jaxb"/>

<target name="compile" depends="check-jaxb" description="Compile all source code.">

<mkdir dir="${classes.dir}"/>

<src path="${src.dir}"/>
<src path="${derived-src.dir}"/>