ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bell, Aaron" <>
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"/>
      <echo>macro called with host '${host}'</echo>
  <target name="test">
    <script language="javascript"> <![CDATA[
      newTask = project.createTask("my-macro");
      newTask.setDynamicAttribute("host", "bingo");
      project.log("new task is: " + newTask.toString());

    ]]> </script>

This returns:

new task is:

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:
For additional commands, e-mail:

View raw message