Macrodef vs script vs javascript

I want to create a task defined by a macrodeck in a script element. I was hoping to find that there would be "set" functions corresponding to each attribute. There is no such luck. Is there any other API for specifying attributes?

 var statustask = project.createTask("service-status");
 statustask.setPath(project.getProperty("path"));
 statustask.setStatusproperty("status");
 statustask.setTimeout=("1"); // this isn't suppose to take a long time.
 statustask.perform();
+5
source share
1 answer

Perhaps you can achieve what you want using the MacroInstance methods (a subclass of Tasks) that you get from the method createTaskfor the macro, This is:

<macrodef name="my.macro">
    <attribute name="attr1" default="NOT SET"/>
    <sequential>
        <echo message="attr1=@{attr1}" />
    </sequential>
</macrodef>

<script language="javascript"><![CDATA[
    var macro = project.createTask( "my.macro" );
    macro.setDynamicAttribute( "attr1", "value_1" );
    macro.execute();
]]></script>

It does this at startup:

[echo] attr1=value_1
+5
source

All Articles