ant-user mailing list archives

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

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.

Conor


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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message