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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -