ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <>
Subject Re: Access project.classpath from a Task
Date Thu, 01 Jul 2004 13:10:59 GMT

It is possible under some circumstances. What you need to do is get the 
ClassLoader instance for your class. If that ClassLoader is an 
AntClassLoader, you can access the equivalent classpath with the 
getClasspath() method.

The instances where this will not work is where your task class is not 
loaded through the loader setup by taskdef and your ClassLoader is not 
an AntClassLoader instance.


Robert Mark Bram wrote:
> Hi All!
> I need to set a classpath in my custom task definition. I also need this 
> classpath within the Java Task itself.
> Is there a way to programmatically access project.classpath from within 
> Java? I tried looking in the Project class but nothing obvious strikes me..
> <project name="OwnTaskExample" default="main" basedir=".">
>    <taskdef
>       name="JavaConsole"
>       classname="common.ant.JavaConsoleTask"
>       classpath="lib/common.jar"/>
>    <target name="main">
>       <JavaConsole
>          title="Testing Console"
>          inputRequired="true"
>          executable="java" />
>    </target>
> </project>
> Any help would be most appreciated!
> Rob
> :)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message