ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Recycle an Ant task
Date Fri, 28 Sep 2012 04:08:15 GMT
On 2012-09-26, Jose Rojas wrote:

> I would like to create a custom ant task that caches some results from an
> operation and saves it for use in future executions.  My simple method of
> doing this is using a 'static' member.  This would work great for me as the
> operations would be appropriate to cache at an application wide level.

A better approach might be to store the data as a reference in the
Project instance (or several of them).

> However what I'm noticing is that for each new execution of Ant (I'm using
> the Ant taskdef to execute ant), the static data is lost, quite possibly
> caused by Ant creating a new class loader upon every execution, thus not
> reusing my ant task class instance from the previous execution.

This would happen if you use multiple taskdefs - i.e. repeat it several
times.  You can pass a name of a class loader to taskdef (the loaderRef
attribute) and Ant will create a class loader on the first execution,
cache it and reuse it for all subsequent task/typedefs that use the same


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

View raw message