ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: creating macro instance from a script task?
Date Thu, 13 Nov 2003 18:12:34 GMT
It looks like the attribute "id" is sent
to DynamicConfigurator#setDynamicAttribute()
I suppose this is to allow setId() to work?

In any case, I will emulate setId()..

Peter
PS: this usage of id's and script I have never liked.

On Thursday 13 November 2003 17:26, Jan.Materne@rzf.fin-nrw.de wrote:
> Ggr - using id´s dont work:
>
> <project default="use">
>
>     <macrodef name="my-echo">
>         <attribute name="message"/>
>         <sequential>
>             <tstamp><format property="x" pattern="HH:mm:ss"/></tstamp>
>             <echo>${x}: ${message}${line.separator}</echo>
>         </sequential>
>     </macrodef>
>
>     <target name="use">
>         <script language="javascript"> <![CDATA[
>             msg1.execute();
>             msg2.execute();
>             msg1.setMessage("A new text.");
>             msg1.execute();
>         ]]> </script>
>     </target>
>
>     <target name="-thisTargetIsNeverCalled">
>         <my-echo id="msg1" message="Hello World"/>
>         <my-echo id="msg2" message="This is a test."/>
>     </target>
>
> </project>
>
>
> When using <echo> in the "-thisTarget..." all works fine. But not with the
> <macrodef>ed.
>     build.xml:14: Unknown attribute [id]
>
>
>
> Sorry
> Jan
>
> > -----Original Message-----
> > From: Bell, Aaron [mailto:Aaron.Bell@bskyb.com]
> > Sent: Thursday, November 13, 2003 6:11 PM
> > To: 'user@ant.apache.org'
> > Subject: creating macro instance from a script task?
> >
> >
> > Hi there
> >
> > I love the new macrodef task in 1.6. However, how can I
> > invoke one of my
> > macrodefs from a script task?
> >
> > I'm using Javascript. I can create a MacroInstance object... when I
> > execute() it though I receive a NullPointerException.
> >
> > Quick example:
> >
> > <project name="test" default="test" basedir=".">
> >
> >   <macrodef name="my-macro">
> >     <attribute name="host"/>
> >     <sequential>
> >       <echo>macro called with host '${host}'</echo>
> >     </sequential>
> >   </macrodef>
> >
> >   <target name="test">
> >     <script language="javascript"> <![CDATA[
> >
> >       newTask = project.createTask("my-macro");
> >       newTask.setDynamicAttribute("host", "bingo");
> >       project.log("new task is: " + newTask.toString());
> >       newTask.execute();
> >
> >     ]]> </script>
> >   </target>
> > </project>
> >
> > This returns:
> >
> > new task is: org.apache.tools.ant.taskdefs.MacroInstance@1b9ce4b
> >
> > BUILD FAILED
> > C:\build\test.xml:16: java.lang.NullPointerException
> >
> > Does anyone have any ideas?
> >
> > Many thanks!
> > - Aaron
> >
> > Aaron Bell
> > CRM Release Management
> > int tel. 5448
> > ext tel. (01506) 485448
> >
> >
> > --------------------------------------------------------------
> > ---------
> > Information in this email may be privileged, confidential and is
> > intended exclusively for the addressee.  The views expressed may
> > not be official policy, but the personal views of the originator.
> > If you have received it in error, please notify the sender by return
> > e-mail and delete it from your system.  You should not reproduce,
> > distribute, store, retransmit, use or disclose its contents to anyone.
> >
> > Please note we reserve the right to monitor all e-mail
> > communication through our internal and external networks.
> > --------------------------------------------------------------
> > ---------
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org


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


Mime
View raw message