I want to create a task defined by a macrodef within a script element. I was hoping to find that there would be 'set' functions corresponding to each attribute. No such luck. Is there some other API for specifying the 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();
You can probably achieve what you want using methods of the MacroInstance (a subclass of Task) you'll get from the createTask
method for a macro. This:
<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>
Produces this when run:
[echo] attr1=value_1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With