If I have placed the optional.jar and junit.jar files into the ant lib directory so that I can run without these files in my CLASSPATH, I am still required to do so when the junit task uses fork=true as the codebase of the junit task is not included in the forked java command line as shown below. So in order to run the forked junit task I need the optional.jar and junit.jar in my CLASSPATH which defeats the purpose of adding these jars to the ant lib directory. build 790>ant -verbose unit-tests Ant version 1.3 compiled on March 2 2001 Buildfile: build.xml Detected Java Version: 1.3 Detected OS: Windows 2000 ... unit-tests: [junit] Executing: java -classpath D:\usr\local\src\cvsroot\jBoss\jbosssx\bu ild\classes;D:\usr\local\src\cvsroot\jBoss\jbosssx\lib\ejb.jar;D:\usr\local\src\ cvsroot\jBoss\jbosssx\lib\jaas.jar;D:\usr\local\src\cvsroot\jBoss\jbosssx\lib\ja xp.jar;D:\usr\local\src\cvsroot\jBoss\jbosssx\lib\jdbc2_0-stdext.jar;D:\usr\loca l\src\cvsroot\jBoss\jbosssx\lib\jmxri.jar;D:\usr\local\src\cvsroot\jBoss\jbosssx \lib\jta-spec1_0_1.jar;D:\usr\local\src\cvsroot\jBoss\jbosssx\lib\crimson.jar;D: \usr\local\src\cvsroot\jBoss\jbosssx\lib\log4j.jar;D:\usr\local\src\cvsroot\jBos s\jboss\dist\lib\ext\jboss.jar;D:\usr\local\src\cvsroot\jBoss\jboss\dist\lib\ext \jnpserver.jar org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner org. jboss.test.LoginModulesTest haltOnError=false haltOnFailure=true formatter=org.a pache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter [junit] java.lang.NoClassDefFoundError: org/apache/tools/ant/taskdefs/option al/junit/JUnitTestRunner
I don't think we should implicitly add Ant's runtime classes to the classpath for <junit> - some things work if you run junit forked but not if you run things in VM, just because we don't include everything from ANT_HOME/lib (tests that require a different XML parser for example). If we had a way to only include the classpath entries that contain the junit task and junit.jar itself, fine. But this may be difficult to find out - I'll investigate this a little. You cannot rely on the task being defined in optional.jar. Finally, you should get a running fork="true" version, if you give a nested classpath element to <junit> that contains all required classes.
fixed for JDK > 1.1 starting with nightly build 2001-07-13