ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Surette <philsure...@home.com>
Subject Re: script documentation
Date Wed, 31 Oct 2001 18:32:11 GMT
I think this should be possible. I'm actually (slowly,
when I have the time) working on building in support
for this with jython. In Jython (as in Rhinoscript,
I believe) you can compile a python class to a 
java class, which can easily subclass an ant Task.
So I'm developing three ant tasks:

1)a task for running jython scripts (basically a more
jython-friendly version of Script task)
2)a task for compiling jython classes to java classes
3)a task for defining & compiling an ant task from a jython
class

So far only task 1) is done :) 

I'm planning on submitting these to the jython group
since (from listening to the jython-dev list) this is
not the sort of thing the ant developers want to 
encourage or maintain.

The third task is the interesting one. You should be
able to define a new task inline in your ant build
like this:

<jytaskdef name="cat">
    def setFile(self, String fileName):
        self.fileName = fileName

    def execute(self):
        print open(self.fileName).read()    
</jytaskdef>

The above snippet would embed the code in a jython
class which extends org.apache.ant.main.Task, 
compile the jython class into a java class,
then define the task.

One of the (anticipated) beauties of this system
is that you could very rapidly create new tasks
by embedding them in your ant script. There would
be an easy path to convert tasks that
seem to be of more general usage into reusable 
tasks; maybe by adding a 'jar' attribute to
the jytaskdef.

I see no reason why you could not do the same 
thing for javascript, and I intend to once/if
I get a workable jython system.

Markus Kohler wrote:
> 
> Hi,
> 
> > -----Original Message-----
> > From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
> > Sent: Wednesday, October 31, 2001 12:00 PM
> > To: Ant Users List; kohler@cms.tecmath.de
> > Subject: Re: script documentation
> >
> >
> > ----- Original Message -----
> > From: "Markus Kohler" <kohler@cms.tecmath.de>
> > > I wonder if it wouldn't be possible to support defining new
> > Tasks just
> > using
> > > Java script(or any other supported scripting language).
> > > I think that could be a very powerfull feature.
> >
> > You could define a <script> "task" within a standalone target (i.e. no
> > depends clause) and <antcall> to it - which would in effect
> > allow you to
> > have re-usable script code that could be used just like a Task.
> >
> > So the power is there!
> 
> Yes. That's how I plan to doit now.
> 
> >
> > Now just share anything slick you can do with it, as I've
> > only seen useful
> > one-liners in <script>.
> >
> 
> Currently I'm calling  my own specific Java code for dumping information
> that is
> inside my jar file. It's not really usefull for general use.
> 
> Anyway I think it would be even cooler, if I could just define some New
> Tasks using javascript, and with my limited knowledge about ANT's design, I
> cannot see why this would be
> difficult to support.
> 
> Markus
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message