ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bell, Aaron" <Aaron.B...@bskyb.com>
Subject creating macro instance from a script task?
Date Thu, 13 Nov 2003 17:10:35 GMT
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


Mime
View raw message