Hello.

I have a target called 'bind' in my build which uses xjc (JAXB .xsd -> .java
compiler) to compile XML schema files into Java sources. Currently, 'bind'
runs on every run of any target that depends on it - ant doesn't know when
the target is up to date. I want it to run only when the source xsd files
are newer than the generated .java files.

At first, the dependset tag looked promising, but I now realise that adding
a dependset will have ant run the target when the dependset indicates it
should *in addition* to the other times it's running (which is always). What
I want is a dependset that has its enclosing target run *only* when it
indicates.

Is this possible?

Cheers,

Eliot Stock
syzygy.net
+44 20 7598 9910

  <target name="bind" depends="init">

    <!-- Only re-run this target when the xsd files are more recent than the
         generated sources (this is NOT the effect this dependset has) -->
    <dependset>
       <srcfilelist dir="schema" files="*.xsd" />
       <srcfilelist dir="schema" files="binding.xjb" />
       <targetfileset dir="gen-src" includes = "**/*.java" />
    </dependset>

    <echo message="Compiling non-generated sources required for binding..."
/>
    <javac destdir="classes" srcdir="src" debug="on">
      <include
name="uk/co/airmiles/web/ypsilon/YpsilonJAXBCalendarConverter.java" />
      <classpath refid="classpath" />
    </javac>

    <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
      <classpath refid="classpath" />
    </taskdef>

    <echo message="Generating Java sources from XSD schema files..." />
    <xjc target="gen-src"
         package="uk.co.airmiles.web.ypsilon"
         binding="schema/binding.xjb">
      <schema file="schema/errorResponse.xsd" />
      <schema file="schema/fareRequest.xsd" />
      <schema file="schema/availRequest.xsd" />
      <schema file="schema/combined.xsd" />
      <schema file="schema/bookingRequest.xsd" />
    </xjc>

    <echo message="Generating Javadoc from generated sources..." />
    <mkdir dir="docs/api" />
    <javadoc packagenames="uk.co.airmiles.web.ypsilon"
             sourcepath="gen-src"
             destdir="docs/api"
             windowtitle="Generated Interfaces for Ypsilon">
      <classpath refid="classpath" />
    </javadoc>
  </target>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to