ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <>
Subject Re: Initializing Task variables at taskdef time?
Date Tue, 19 Aug 2008 13:38:02 GMT
On Tue, Aug 19, 2008 at 7:56 AM, cowwoc <> wrote:
> This seems like such an obvious use-case but from what I read in this forum
> there doesn't seem to be a way to do it... is there a way for me to pass
> parameters to my custom task at taskdef (initialization time)?
> One obvious use-case is grabbing the classpath used in the taskdef during
> the task execution time, but this could pretty much apply to any variable I
> want to initialize *once* and reuse anytime the task is invoked. Is this
> possible in Ant 1.7?

No. taskdef only loads the class for the task, and doesn't instantiate
it. Plus every time you execute a task, you are typically running it
using a new instance of the task class every time, so no state carries
over from one invocation to the next, unless you explicitly using
statics. If you need cross-invocation state, put it in a datatype that
you pass by reference to all your task's invocations. --DD

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

View raw message