I'm using Cygwin under Windows XP, and I'm trying to get Ant to use JUnit without coding any classpath entries for it. The doc for JUnit says I can:
Put both junit.jar and ant-junit.jar in ANT_HOME/lib.
My handy-dandy copy of JUnit in Action says:
You may have noticed that you don't explicitly add the JUnit JAR to the classpath. Remember that when you installed Ant, you copied the JUnit JAR file to the ${ANT_HOME}/lib directory in order to use the junit Ant task. Because junit.jar is already on your classpath, you don't need to specify it in the javac task to compile your tests.
$ANT_HOME is set to the Ant installation directory. In the lib subdirectory, I see ant-junit.jar (installed with Ant) and junit-4.9.jar (copied by me). Seems okay, right? But the test compile step fails:
[javac] Compiling 1 source file to E:\tools\ctg\bin\test
[javac] E:\tools\ctg\src\test\TestAll.java:3: package org.junit does not exist
[javac] import org.junit.*;
Et cetera. I tried renaming junit-4.9.jar to junit.jar. No joy. I peeked in the jar file and saw that the package does exist inside of it. In fact, the compiles work fine if I explicitly include that very jar file in the Ant classpath.
Bleh. Any thoughts about what might be wrong? Thanks.
EDIT: By request, here's the javac target:
<path id="classpath">
<pathelement location="${app-bin}"/>
<pathelement location="${test-bin}"/>
<!--pathelement location="${junit-bin}"/-->
</path>
<target name="compile-test" depends="compile-app">
<javac srcdir="${test-src}"
destdir="${test-bin}"
source="${java}"
target="${java}"
debug="on"
includeantruntime="false">
<compilerarg value="-Xlint"/>
<classpath refid="classpath"/>
</javac>
</target>
Note that the JUnit binary is commented out. My goal is to delete it and have the compile work.