We compress our javascript (and css files) with YUI compressor during our ant build task running on our Jenkins CI Server. However, it is very difficult to determine which js files YUI compressor is having errors with. We see a bunch of things like:
[minify-js] [ERROR] 3:35:unterminated string literal [minify-js] [minify-js] [ERROR] 3:35:syntax error [minify-js] [minify-js] [ERROR] 4:8:syntax error [minify-js] [minify-js] [ERROR] 1:0:Compilation produced 3 syntax errors. [minify-js] org.mozilla.javascript.EvaluatorException: Compilation produced 3 syntax errors. [minify-js] at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:135) [minify-js] at org.mozilla.javascript.Parser.parse(Parser.java:410) [minify-js] at org.mozilla.javascript.Parser.parse(Parser.java:355) [minify-js] at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312) [minify-js] at com.yahoo.platform.yui.compressor.JavaScriptCompressor.(JavaScriptCompressor.java:533) [minify-js] at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:112) [minify-js] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [minify-js] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [minify-js] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [minify-js] at java.lang.reflect.Method.invoke(Method.java:616) [minify-js] at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:20) [minify-js] Result: 2
in the output, but I have no idea which of the hundreds of JS files the error is coming from. Our ant task looks like:
<target name="minify-js">
<apply executable="yuicompressor" parallel="false" dest="${global.dir}/" taskname="minify-js" force="true">
<fileset dir="${global.dir}/" includes="**/*.js">
<exclude name="*.min.js" />
</fileset>
<arg value="--type=js" />
<srcfile />
<arg value="-o" />
<targetfile />
<mapper type="identity" />
</apply>
</target>
Not being an expert on Ant or YUI compressor, is there something we can do so that the filename where there error is happening is output somewhere?
I don’t know how the yuicompressor works, I assume that it works on one file at a time.
If this is true, you can do it with for from ant-contrib. You would need to install ant-contrib prior.