[jsword-devel] Ant + generated sources

Mark Goodwin jsword-devel@crosswire.org
23 Apr 2003 11:58:50 +0100


I've had a couple of problems building after CVS updates recently. The
problems have all been to do with generated sources (OSIS / config

The problems were simple to fix; a quick look at the ant script revealed
that all I needed to do was an "ant veryclean" to nuke old generated
files.  I say 'all', because then, of course, I had to do an "ant all"
which takes between a quarter of an hour and 20 minutes on my machine
(yes, I should get a new one)..... which brings me to my question: 

Is there any reason why we shouldn't have something like a "source.gen"
target that just does the necessary generation?  E.g. an "ant xjc
check.config" does this for me from a very clean tree (even though the
current check.config fails in the javac task). This way to get working
sources again from a major update (or new checkout) all that would be
necessary would be "ant veryclean source.gen" (takes just under 40
seconds on my machine using the suggestion below).

All that would need doing is something like this:

  <target name="check.config" depends="config.gen">
  <!-- stuff in config.gen used to be at the start of this target -->
    <mkdir dir="${target.classes}/config"/>
    <javac debug="on" includes="**/*.java"
      <src path="${gener.root}/config"/>
        <dirset dir="${target.classes}"/>
        <fileset dir="${source.jar}" includes="**/*.jar"/>

  <target name="config.gen">
  <!-- generate the config sources -->
    <mkdir dir="${gener.root}/config"/>
  <!-- generate sources -->
  <target name="source.gen" depends="xjc, config.gen" />

What do you think?