title: How to make Ant prefer classes from a linked JAR over JDK classes?
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>Here's the relevant Ant code:</p>
  
  <pre><code>&lt;path id="compile.classpath"&gt;
      &lt;fileset dir="./lib/endorsed"&gt;
          &lt;include name="*.jar" /&gt;
      &lt;/fileset&gt;
      &lt;fileset dir="./lib"&gt;
          &lt;include name="*.jar" /&gt;
      &lt;/fileset&gt;
  &lt;/path&gt;
  
    &lt;target name="compile" depends="prepare-src"&gt;
      &lt;javac srcdir="${build.src}"
             destdir="${build.dest}"
             debug="${debug}"
             optimize="${optimize}"
             target="1.3"
             source="1.3"
             deprecation="${deprecation}"
             classpathref="compile.classpath"&gt;
      &lt;/javac&gt;
    &lt;/target&gt;
  </code></pre>
  
  <p>the JAR that should be used is in lib/endorsed, but it's not used during compilation.</p>
  
  <p>How come?</p>