I've try this but I still get a junit/framework/TestListener class not
found error. Note that my junit.jar is not in the same ant's lib
directory. I'm using JUnit 3.5 and Ant 1.3b3. Here is the stack trace:
/home/wlee/smi/SendmailGUI/dist/turbine/webapps/ListEditor/WEB-INF/build/build.xml:210:
Could not create task of type: junit due to
java.lang.NoClassDefFoundError: junit/framework/TestListener
--- Nested Exception ---
java.lang.NoClassDefFoundError: junit/framework/TestListener
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at org.apache.tools.ant.Project.createTask(Project.java:439)
at
org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:83)
at org.apache.tools.ant.Target.execute(Target.java:152)
at org.apache.tools.ant.Project.runTarget(Project.java:898)
at org.apache.tools.ant.Project.executeTarget(Project.java:536)
at org.apache.tools.ant.Project.executeTargets(Project.java:510)
at org.apache.tools.ant.Main.runBuild(Main.java:421)
at org.apache.tools.ant.Main.main(Main.java:149)
The build file would work if I specify the junit.jar in the
LOCALCLASSPATH variable in the script that invokes Ant.
Can anyone tell me why?
Will
Nico Seessle wrote:
>
> ----- Original Message -----
> From: "William Lee" <[EMAIL PROTECTED]>
> To: "Ant User" <[EMAIL PROTECTED]>
> Sent: Thursday, March 01, 2001 6:47 PM
> Subject: Setting classpath for optional task
>
> > Is there a way I can set the classpath for the optional tasks WITHIN the
> > ant build.xml? For now, if I want to use a task such as JUnit, I need
> > to set the classpath explicitly before I call the ant main class. Since
> > I don't really want to depend on the environment variable CLASSPATH for
> > various reasons, I can't really use the "ant" script to invoke the
> > build.xml that has a JUunit task. I ended up writing something similar
> > to the "ant" with my custom CLASSPATH. Is there anyway to get around
> > it?
>
> You could try to "redefine" the junit-task using something like
>
> <taskdef name="junit"
> classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
> <classpath>
> <fileset dir="./lib">
> <include name="junit.jar"/>
> </fileset>
> </classpath>
> </taskdef>
>
> Don't know if this works (and if I have made some errors above) - just try
> it.
>
> Nico