title: Ant classpath and junit.jar
body: <p>I have the an build.xml that allows me to run junit tests. Here is the relevant part:</p>
  
  <pre><code>&lt;path id="JUnit 4.libraryclasspath"&gt;
      &lt;pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/&gt;
      &lt;pathelement location="../../../../../eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/&gt;
  &lt;/path&gt;
  &lt;path id="MyProject.classpath"&gt;
      &lt;pathelement location="bin"/&gt;
      &lt;path refid="JUnit 4.libraryclasspath"/&gt;
  &lt;/path&gt;
  
  &lt;target name="run_unit_tests" depends="build"&gt;
          &lt;mkdir dir="${junit.output.dir}"/&gt;
          &lt;junit printsummary="yes" haltonfailure="no"&gt;   
              &lt;classpath refid="MyProject.classpath" /&gt;
  
              &lt;formatter type="xml"/&gt;
              &lt;batchtest todir="${junit.output.dir}"&gt;
                      &lt;fileset dir="${src}"&gt;
                              &lt;include name="**/*Test*.java"/&gt;
                      &lt;/fileset&gt;
              &lt;/batchtest&gt;
          &lt;/junit&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>If I replace the line:</p>
  
  <pre><code>&lt;pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/&gt;
  </code></pre>
  
  <p>with </p>
  
  <pre><code>&lt;pathelement location="${eclipse.home}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/&gt;
  </code></pre>
  
  <p>The change breaks the classpath. I get the following error:</p>
  
  <blockquote>
    <p>The <code>&lt;classpath&gt;</code> for <code>&lt;junit&gt;</code> must
    include junit.jar if not in Ant's own
    classpath</p>
  </blockquote>
  
  <p>As far as I understand, the location attribute should hold the same value in both cases. So what can be the reason?</p>
  
  <p>As a side question, this build file will not work on an environment with different junit version (the path will break). Is it possible to add a "general" path to junit.jar? </p>