Within Ant
, I am creating a macrodef that utilizes javascript
to handle the task of validating a given timezone
.
<macrodef name="validateTimeZone">
<attribute name="zone" />
<sequential>
<echo>result: ${envTZResult}</echo>
<echo> validating timezone: @{zone}</echo>
<script language="javascript"><![CDATA[
importClass(java.util.TimeZone);
importClass(java.util.Arrays);
var tz = project.getProperty("zone");
println(" got attribute: " + tz);
var result = Arrays.asList(TimeZone.getAvailableIDs()).contains(tz); // Check if timezone is valid
project.setProperty("zoneIsValid", result);
]]>
</script>
</sequential>
</macrodef>
An issue arises with project.getProperty()
as it does not retrieve the values of passed attributes. Is there a method to access the value of the attribute from within the javascript code?