Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 1356 invoked from network); 27 Apr 2004 11:43:51 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 27 Apr 2004 11:43:51 -0000 Received: (qmail 43468 invoked by uid 500); 27 Apr 2004 11:43:12 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 43416 invoked by uid 500); 27 Apr 2004 11:43:12 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 43325 invoked from network); 27 Apr 2004 11:43:11 -0000 Received: from unknown (HELO corvil.com) (213.94.219.177) by daedalus.apache.org with SMTP; 27 Apr 2004 11:43:11 -0000 Received: from corvil.com (angel.local.corvil.com [172.18.1.171]) by corvil.com (8.12.9/8.12.5) with ESMTP id i3RBhBo7092033 for ; Tue, 27 Apr 2004 12:43:11 +0100 (IST) (envelope-from peter.reilly@corvil.com) Message-ID: <408E47D4.9080004@corvil.com> Date: Tue, 27 Apr 2004 12:45:24 +0100 From: Peter Reilly User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ant Users List Subject: Re: Article: Use Jython to Write Ant Tasks References: <8729439.1082777204337.JavaMail.root@misspiggy.psp.pas.earthlink.net> <408CDB5C.2070702@corvil.com> <6.0.2.0.2.20040426173622.01d36ec0@pop.earthlink.net> In-Reply-To: <6.0.2.0.2.20040426173622.01d36ec0@pop.earthlink.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Scripttypedef is a task that may be in ant 1.7. It is like except that it uses reflection on a class provided by a BSH script to find the attributes and nested elements. It may also be used to make Conditions, Filters , FilenameMappers and Selectors. import org.apache.tools.ant.Task; public class ByTwo extends Task { private int value = 1; public void setValue(int value) { this.value = value; } public void execute() { log("bytwo is " + (value * 2)); } } import org.apache.tools.ant.Task public class ByThree extends Task { int value = 1 public void execute() { log("bythree is " + (value * 3)) } } ByThree Peter Ed Taekema wrote: > Not sure what you need to do to support scripttypedef ... but you can > access the project as the following code demonstrates: > > def startSession(self): > > project = Task.getProject(self) > project.setProperty("SESSION_ADDR", "XXXX"); > > Does the task need to "self register"? or does it register as part of > its constructor? > > Ed > > > \At 03:50 AM 4/26/2004, Peter Reilly wrote: > >> Hi Ed, >> This is a interresting article - I did not know about the """@sig " >> trick. >> >> I tried to do the following using ant's script task: >> >> from org.apache.tools.ant import Task >> >> class SimpleTask(Task): >> >> message = "" >> >> def execute(self): >> """@sig public void execute()""" >> Task.log(self, "Message: " + self.message) >> >> def setMessage(this, aMessage): >> """@sig public void setMessage(java.lang.String str)""" >> this.message = aMessage >> >> project.addTaskDefinition("s", SimpleTask) >> >> But when the task is used, I get: >> ImportError: no module named main >> >> This is a pity as it would be nice to add jython to the >> languages supported by . >> >> >> The groovy example would be more groovly written: >> >> import org.apache.tools.ant.Task >> public class GroovySimpleTask extends Task { >> String message = "" >> public void execute() { >> log(message) >> } >> } >> >> project.addTaskDefinition("s", GroovySimpleTask) >> >> >> Peter >> >> >> Ed Taekema wrote: >> >>> I've written a guide to writing Ant tasks using Jython: how to add >>> scripted behaviour >>> to ant builds. It details the steps to write a custom Ant task in >>> jython, compile >>> it and install it into ant so it can be used as any other task in an >>> ant build. The article also takes a quick look at an alternate >>> implementation using Groovy. >>> >>> And ... here is the url: >>> http://www.pycs.net/users/0000177/stories/11.html . >>> >>> Enjoy, >>> >>> Ed Taekema >>> Toronto, Canada >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org