This particular question has been asked a few times, but not quite to my satisfaction. I'm not really interested in the workarounds proposed, but how to do what I actually want to do.
Would like a satisfactory explanation for why this is not possible if it isn't, and since I would propose to submit a fix for this myself I'd like to get an understanding for why something that seems so straightforward has not been attempted.
Currently, to ensure that a set of jars are available to ant, one of the following approaches must be applied:
- add to
CLASSPATH
environment variable - "not recommended" in documentation - add to
$ANT_HOME/lib
or~/.ant/lib
- requires configuration in build environment - set
-lib
parameter onant
invocation
The final option is what I have settled upon as the preferred one, but it still requires some intervention by the person invoking the build (which I have captured within an ant
wrapper-script in my development repository).
In particular I am trying to invoke the Schematron Ant task which should be set up according to the documentation like this:
<taskdef name="schematron"
classname="com.schematron.ant.SchematronTask"
classpath="lib/ant-schematron.jar"/>
however this has a transitive dependency on saxon, so without a saxon.jar
available on the CLASSPATH
, the build fails:
java.lang.NoClassDefFoundError: net/sf/saxon/TransformerFactoryImpl
The ant documentation itself goes on to suggest that it should be the taskdef itself that takes these additional CLASSPATH
entries, but I've tried this with the schematron ant-task to no avail.
Key questions are whether it should be schematron ant task that should support this, or should it be possible for the ant build.xml to have its global classpath configured within itself?
It seems as though this is something that people would want to do quite often, and since the ant docs themselves recommend not using CLASSPATH themselves I'm surprised there is no alternative within build.xml itself!