ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Classloader question
Date Mon, 01 Oct 2001 11:16:10 GMT

I am trying to get rid of the issues that popped up recently with Ant 1.4
and Velocity.  I will phrase the question generally...

How do I, in a custom Ant task, dependably access the 'task classloader'?

Here's the issue I believe I am facing.  Suppose I have the following :

<target name="foo">
    <taskdef name="texen"
        <pathelement location="../test/texen-classpath/test.jar"/>
        <path refid="classpath"/>

Now, in the Texen code, I want to, via a classloader, access the stuff added
to the  classpath defined in the <taskdef/>.

What we were doing was something on the order of

  ClassLoader cl = this.getClass().getClassLoader();

But that doesn't fly in 1.4 as it appears that 1.4 delegates upwards for
classloading (rather than downwards...)  I may have the interpretation of
the cause  wrong - the symptom is that if you put the jar with Texen (the
velocity.jar) in the classpath before invoking ant, you get the problem.  If
you don't, all is fine.

So what I want to do is ensure I always get the 'lower' classloader (or find
another solution.)



Geir Magnusson Jr.
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin

View raw message