ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Putting Classpath Into My Own Ant Task
Date Thu, 10 Jun 2004 09:13:33 GMT
On Jun 9, 2004, at 1:10 PM, Dominique Devienne wrote:
>> From: Dave Westerman []
>> I am writing my own Ant task as a wrapper to a utility which I have
>> written. I have 3rd-party jar files which my utility needs in order to
>> run. The Ant manual suggests that you always allow a user of your 
>> task to
>> specify the classpath. I'm assuming I should use the builtin embedded
>> <classpath> element. But I can find no examples of doing this.
>> I'm assuming I need a createClasspath() method, and a 
>> setClasspath(Path)
>> method in my Ant task. But how do I then use the new classpath? Do I 
>> have
>> to use the Ant Java task to call my utility class, instead of calling 
>> it
>> directly from my Ant task, so that I can pass in the new classpath?
>> Any help would be greatly appreciated!
> No, no, no. If your task depend on 3rd party classes, then it will 
> never be
> loaded unless these classes are available, so your task having a 
> <classpath>
> nested element does no good.
> The 3rd party classes you require either must be in the system 
> in ant/lib (as JARs), or specified explicitly at <taskdef> time in a 
> nested
> <classpath>. --DD

Or, you could use the <java> task through the API allowing you to 
control the classpath and fork and such.  This is what Dave asked about 
later in his original e-mail - and this is the approach I'd recommend.  
I wrote an article about it a while ago for JavaPro magazine:

Look page 7, listing 4 for details on using <java> in this manner.


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

View raw message