Return-Path: X-Original-To: apmail-ant-user-archive@www.apache.org Delivered-To: apmail-ant-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 02AC2D216 for ; Fri, 28 Sep 2012 04:08:51 +0000 (UTC) Received: (qmail 72170 invoked by uid 500); 28 Sep 2012 04:08:51 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 71414 invoked by uid 500); 28 Sep 2012 04:08:44 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 71371 invoked by uid 99); 28 Sep 2012 04:08:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 04:08:43 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=FSL_RCVD_USER,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [88.84.128.168] (HELO samaflost.de) (88.84.128.168) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 04:08:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by samaflost.de (Postfix) with ESMTP id E20574150035 for ; Fri, 28 Sep 2012 06:08:15 +0200 (CEST) Received: from samaflost.de ([127.0.0.1]) by localhost (v35516.1blu.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ATkFnoWAFyAJ for ; Fri, 28 Sep 2012 06:08:15 +0200 (CEST) Received: by samaflost.de (Postfix, from userid 1000) id A605B4150053; Fri, 28 Sep 2012 06:08:15 +0200 (CEST) From: Stefan Bodewig To: user@ant.apache.org Subject: Re: Recycle an Ant task References: Date: Fri, 28 Sep 2012 06:08:15 +0200 In-Reply-To: (Jose Rojas's message of "Wed, 26 Sep 2012 14:45:24 -0700") Message-ID: <87y5jueqmo.fsf@v35516.1blu.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Virus-Checked: Checked by ClamAV on apache.org 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 name. Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org