javascript - Ant: how to fail if property contains a certain string -
i want write ant macro call fail task if supplied attribute contains string. way know how string comparison in ant using javascript. have this:
<macrodef name="check-for-error"> <attribute name="input"/> <sequential> <echo message="@{input}"/> <script language="javascript"> <![cdata[ var response= "@{input}"; if(response.indexof("fail") !=-1){ project.setproperty("error","true"); } ]]> </script> <fail message="input failed" if="${error}"/> </sequential> </macrodef>
the problem approach i'm setting property global inside of javascript, , ant not let reset property. know ant has ability set local properties. how can access local properties within javascript? or there better way together?
<condition property="missing-properties"> <matches pattern="your-pattern" string="${the-attribute}"/> </condition> <fail message="input failed!" if="missing-properties"/>
Comments
Post a Comment