ant javascript failonerror -
i have ant task includes embedded javascript. i'd have target fail or succeed based on logic run in 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); } //setup source directory srcdir = project.getproperty("my_home") + "/foo/src"; if(srcdir.startswith("/foo") { //target should pass } else { //target should fail } ]]> </script> </target>
you make ant exit via exit api, throws build exception lead messy stack trace. cleanest method set property in javascript test using fail
task:
javascript:
project.setproperty( "javascript.fail.message", "there problem" );
ant, after script task:
<fail if="javascript.fail.message" message="${javascript.fail.message}" />
Comments
Post a Comment