ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: Embedded dynamic ANT tasks.
Date Fri, 06 Jun 2003 16:17:04 GMT
This is AWESOME

This is something I have been looking for in a long time.

Using a slighty moded bsh (com.ibm->org.apache), this
also works with ant 1.6 nightly.

Peter

On Friday 06 June 2003 15:53, Dawid Weiss wrote:
> Dear ANT community,
>
> I thought one day: maybe it would be fun if I could define ANT tasks INSIDE
>
> the  ANT  script that is being executed? So it could look like this:
> > <!-- Define an embedded task and use it immediately -->
> > <target name="example" depends="prepare">
> >
> >     <!-- define the task -->
> >     <embeddedtaskdef name="counterTask"><![CDATA[
> >         String message;
> >         int    min;
> >         int    max;
> >
> >         void setMin(int min) {
> >             // note how 'global' is used instead of 'this'
> >             // global scope refers to the task instance anyway.
> >             global.min = min;
> >         }
> >
> >         void setMax(int max) {
> >             global.max = max;
> >         }
> >
> >         void setMessage(String message) {
> >             global.message = message;
> >         }
> >
> >         void execute() {
> >             if (message != null)
> >                 System.out.print(message);
> >             for (int i=min;i<max;i++) {
> >                 System.out.print(i);
> >                 if (i+1 != max) System.out.print(",");
> >             }
> >         }
> >     ]]></embeddedtaskdef>
> >
> >     <!-- use the defined task right away! -->
> >     <counterTask min="0" max="10" message="The numbers from 0 to 10 are:
> > " /> <counterTask min="5" max="20" message="And the numbers from 5 to 20
> > are: " /> </target>
>
> I've played with BSH and BCEL and the solution can be found at:
>
> http://www.cs.put.poznan.pl/dweiss/index.php/projects/bsh-binding/index.xml
>?lang=en
>
> I  personally find it quite a useful task, even though it started purely as
> a toy and a mind-exerciser :)
>
> Regards,
> Dawid
>
> _______________________
> Dawid Weiss, http://www.cs.put.poznan.pl/dweiss
> Laboratory of Intelligent Decision Support Systems, Poznan UT, Poland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message