I am trying to build the dom4j JAR, which includes an xml-apis JAR which contains a DOM API that is older than that shipped with more recent JDKs.
However, even though in the build file the source and target compiler attributes are set to 1.3, and even though the xml-apis JAR is included in the build path, Ant still tries to compile dom4j against another, newer, w3c API (I guess one from a JDK installation).
Here's the relevant Ant code:
<path id="compile.classpath">
<fileset dir="./lib/endorsed">
<include name="*.jar" />
</fileset>
<fileset dir="./lib">
<include name="*.jar" />
</fileset>
</path>
<target name="compile" depends="prepare-src">
<javac srcdir="${build.src}"
destdir="${build.dest}"
debug="${debug}"
optimize="${optimize}"
target="1.3"
source="1.3"
deprecation="${deprecation}"
classpathref="compile.classpath">
</javac>
</target>
the JAR that should be used is in lib/endorsed, but it's not used during compilation.
How come?
You could modify the boot classpath and there is support for that with a specific attribute in ANT, but I think it should be the
java.endorsed.dirs
property (in raw javac):Or with a
compilerarg
ANT sub-element:You shouldn't add the
endorsed
directory to the classpath as the boot classpath and any endorsed directories are checked before the classpath to resolve required types. This would mean the JDK's newer DOM implementation would be found first.You could try to exclude Your old lib.
Use the
bootclasspath
/bootclasspathref
attribute.Just for reference, this can be achieved using maven like so,