本文介绍了确定哪些文件有错误,从蚂蚁运行YUI COM pressor时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们COM preSS我们的詹金斯CI服务器上运行我们的JavaScript(和CSS文件)与YUI COM pressor我们的Ant构建任务中。然而,这是非常难以确定哪个JS文件YUI COM pressor正与错误。我们看到像一堆东西:

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

在输出中,但我不知道几百JS的哪些文件错误的来源。我们的Ant任务如下:

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>

由于不是蚂蚁或YUI COM pressor的专家,是有什么我们可以做这样的文件名哪里有错误发生的事情是输出的地方?

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?

推荐答案

我不知道yuicom pressor是如何工作的,我认为它可以在一个文件上的时间。

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.

<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${global.dir}/bin_data/ant-contrib-0.6.jar"/>
<for param="file">
  <path>
    <fileset dir="${global.dir}/" includes="**/*.js">
      <exclude name="*.min.js" />
    </fileset>
  </path>
  <sequential>
    <echo>youcompressor for @{file}</echo> <!-- Will output each file and help debugging -->
    <exec executable="yuicompressor"> <!-- I took the args from the official documentation-->
      <arg value="--type=js" />
      <arg value="-o" />
      <arg value="'.js$:-min.js'" />
      <arg value="@{file}" />
    </exec>
  </sequential>
</for>

这篇关于确定哪些文件有错误,从蚂蚁运行YUI COM pressor时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 06:08