原来我使用了错误的标签类型。为了使用脚本定义蚂蚁任务,我应该使用
scriptdefnot
macrodef。使用
scriptdef预定义的对象可以访问任务中的属性和嵌套元素。
这适用于从Ant中的javascript访问属性:
<scriptdef name="validateTimeZone" language="javascript"> <attribute name="zone" /> <![CDATA[ importClass(java.util.TimeZone); importClass(java.util.Arrays); var tz = attributes.get("zone"); //get attribute defined for scriptdef println(" got attribute: " + tz); var result = Arrays.asList(TimeZone.getAvailableIDs()).contains(tz); //testing if timezone is known project.setProperty("zoneIsValid", result); ]]> </scriptdef>


