----- Original Message -----
From: Stefan Bodewig <[EMAIL PROTECTED]>
> > Now, my classpath is set up properly, because my TestCase is loading
> > and running (obviously).
>
> Uhm, no, not obviously, sorry.
But...but...{blank stare}
> <taskdef> will consult the system classloader, your testcase has been
> loaded by the classloader that has loaded the testrunner in your
> <junit> task.
{time passes as our hero uses his small brain to understand this}
I thought taskdef used a new AntClassLoader, as in Definer.java line
275? (Ant 1.5.3) I guess that must consult the system classloader
first...?
> If you provided a <classpath> to <junit>, its content
> will not necessarily be available to <taskdef>.
OK. Still puzzled, but OK.
> Say, all Ant classes are on the system classpath - most likely unless
> you are running a very very recent nightly build.
>
> <junit> loads JUnitTestRunner from system classloader, this one loads
> your testcase using the classpath you've specified, fine.
With you so far.
> Your testcase load Project, which in turn gets loaded from the system
> classloader as it is available there and the classloader used to load
> your testcase delegates to its parent before trying to load a class
> itself.
Right; my debug output says, among other things:
Class org.apache.tools.ant.Project loaded from parent loader
> Project in turn loads Taskdef and at this point, all information about
> the classloader that has loaded your testcase has been lost.
Aah. OK.
> > Is there something else I have to do to enable ant's tangled
> guts to
> > look in the right place to find my taskdef class?
>
> Certainly. 8-)
>
> (1) use fork on your <junit> task - this means that all that has been
> in <classpath> will now be on the system classloader.
Well, the dirty little secret here is that the project that is running
this test case is actually using Maven, and I don't think Maven forks
JUnit tests...I'll have to investigate this.
> (2) Add a nested <classpath path="mypath"/> to your taskdefs and a
> <sysproperty> to <junit> to pass your classpath as a system property
> to the build file.
OK. That is probably the least ugly solution.
> (3) Load Project via the classloader for your testcase yourself,
> bypassing the system classloader. This will not only be tricky but
> almost certainly result in LinkageErrors or ClassCastExceptions.
>
> Probably other options as well.
I was playing around with Project.setCoreLoader(); perhaps I could set
a classloader that *doesn't* delegate to its parent? Not sure.
Thanks for your quick and helpful reply.
Cheers,
Laird
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]