I want to write an ant macro that will fail if the incoming attribute contains a specific string. The only way I know how to do string comparisons in ant is to use javascript. I have something like 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 with this approach is that I am setting a property that is global inside javascript, and ant does not allow you to reset the property. I know that ant has the ability to set local properties. How can I access local properties from javascript? Or is there a better way to do this all together?
javascript ant
Kyle
source share