ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Access to custom task's classpath?
Date Tue, 14 Oct 2008 04:10:25 GMT
On Mon, 13 Oct 2008, Jeremy Mawson <jem.mawson@gmail.com> wrote:

> I have a custom task defined thus:
> 
> <taskdef resource="task.properties" classpathref="task.class.path"/>
> 
> The classpathref contains the jar which includes both my Task and a
> file resource. When I try to obtain the resource in the Task at
> runtime I'm unable to find it.

You should be able to load it with MyTask.class.getResource().

> When I print out the java.class.path property in the task, it does
> not include the jar my Task is in!

This property only reflect what the system classloader sees.  Your
task has been loaded by a different classloader that has your custom
jars in it as well.  You can get this ClassLoader via
MyTask.class.getClassLoader().

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message