Today I spent a couple of hours with this problem. I had .jar files all specified in Eclipse via Project | Properties | Java build path but still getting
<classpath> for <junit> must include junit.jar if not in Ant own classpath
when running Ant from Eclipse.
Running Ant from the command line will work fine (I had everything in the classpath environment variable).
But in Eclipse, the only thing that worked was to explicitly specify the class path inside the elements, for example:
<path id="JUnit 4.libraryclasspath"> <pathelement location="...\plugins\org.junit_4.11.0.v201303080030\junit.jar"/> <pathelement location="...\plugins\org.hamcrest.core_1.3.0.v201303031735.jar"/> <pathelement location="...\lib\ant-junit4.jar"/> </path> <path id="Ant1.classpath"> <pathelement location="bin"/> <pathelement location="."/> <path refid="JUnit 4.libraryclasspath"/> </path> ... stuff... <target name="test1" depends="compile"> <junit> <classpath refid="Ant1.classpath"/> </junit> </target>
Without explicitly specifying the class path in the junit element, it will break the eclipse every time, even just bare
<junit/>
link
I am not an expert, I just report that it works today.
-ctb
CharlesTBetz
source share