|
From: Phil S. <phi...@ho...> - 2001-11-02 07:43:28
|
Finn Bock wrote: > > [Phil Surette] > > >Yeah, I'm doing that. > > > >I'm writing three tasks: > >1) a jython task. This is like the ant <script> task > >but it has several improvements: > > - handles indented jython scripts. > > - massages stack traces to make line numbers relative to > >the ant build file, rather than relative to the start of the > >script within the build file By the way, I gave up on figuring out how PyTracebacks work (too many PyObjects) and ended up doing a regex thing to patch up the line numbers. Am I missing some critical piece of information? > > - auto-imports some packages (right now, os, os.path, > >sys, string, re) - interetes to hear if others think > >this is a good/evil feature > > This part is evil. Rule #2 clearly says that explicit is better than > implicit. > http://www.python.org/doc/Humor.html#zen > > If you really think it is usefull, I can't see any problems with adding > a xml attribute to the jython tag to enable automatic import of some > modules, say: > > <jython autoimports="true"> > os.mkdir("newdir") > </jython> > I admit that it is evil. However, it is also something that I want; otherwise my embedded scripts are often more than 50% imports. I am planning to add options for controlling it but haven't worked them out yet. Once I have maybe I'll propose a vote. > > - saves typing <jython> vs <script language="jpython"> > >The jython task is working. > > Cool. > > >2) jythonc task - haven't started yet, hopefully tonight. > > > >3) jytaskdef task - define an ant task from within an > >ant build file. You write some jython code with (at > >the minimum) an execute(self) method; this code gets > >embedded in a jython class that extends org.apache.an.main.Task; > >this gets compiled with jythonc; > > Is the jythonc step needed? Maybe I misunderstand the intention behind > jytaskdef, but from your description, I imagine something like: > > <jytaskdef taskname="MyTask"> > import org > class MyTask(org.apache.tools.ant.Task): > def execute(self): > print "Do something usefull" > </jytaskdef> > > jytaskdef would then call project.addTaskDefinition("MyTask", MyTask). > > So, how big is my misunderstanding? Well, I didn't think that you could call jython classes directly from java... ant needs to be able to load the class in a classloader and call various setxxx methods and then call execute. Maybe jython is even more magical than I thought? > > >then the task is defined > >and available everywhere in the build script. > > > >I do not expect that the ant developers will like/want to > >maintain task #3... however I think it will be very useful. > > I'm not sure I would want the jakarta people to maintain #2. We should > be able to add new options to the jythonc and ensure that ant > integration is in sync. Assuming it is technically possible to include > the task in jython.jar, I would prefer to maintain it outself. > > OTOH, I have never maintained an ant Task. If the ant project changes > the API between every ant release it may to big a job to keep up with > them. > > >Anyway, I'll submit the tasks to the jython group when > >they're ready. > > Nice. > > regards, > finn > > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-dev |