I am trying to implement an Ant task that involves adding JavaScript code. I want the success or failure of the target to be determined by the results of some logic executed in the JavaScript:
<target name="analyze">
<script language="javascript">
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader)
importClass(java.io.BufferedReader)
String.prototype.startsWith = function(str) {
return (this.indexOf(str) === 0);
}
String.prototype.endsWith = function(str) {
var lastIndex = this.lastIndexOf(str);
return (lastIndex != -1) && (lastIndex + str.length == this.length);
}
//setting up the source directory
srcDir = project.getProperty("MY_HOME") + "/foo/src";
if(srcDir.startsWith("/foo")) {
//TARGET SHOULD PASS
} else {
//TARGET SHOULD FAIL
}
]]>
</script>
</target>