Ant:如何从另一个具有属性的 scriptdef 调用脚本

Ant: how to call a script from another scriptdef with an attribute

我想互相调用一个脚本:

<scriptdef name="script-to-call" language="javascript">
  <attribute name="myattr" />
  <![CDATA[
    var myattr = attributes.get("myattr");
    // ... do something
  ]]>
</scriptdef>

我试试这个,但我得到了

TypeError: Cannot find function setMyattr

<scriptdef name="caller-script" language="javascript">
  <![CDATA[
    var task = project.createTask("script-to-call");
    task.setMyattr("some value");
    task.perform();
  ]]>
</scriptdef>

这是解决方案:

var task = project.createTask("script-to-call");
task.setDynamicAttribute("myattr", "some value");
task.perform();