简体   繁体   中英

YUI compressor compress all javascripts files into 'min.js'

I want to compress all the javascripts files in a folder to 'min.js', however, the '*' seems doesn't work. Following is my 'build.xml'

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="compressScript" name="compress">

    <target name="compressScript">

        <exec executable="java" failonerror="true">
            <arg line="-jar yui/yuicompressor-2.4.8.jar --nomunge -o '.js$:.min.js' '*.js'"/>
        </exec>

    </target>

</project>

The errors are like this:

compressScript:
 [exec] java.io.FileNotFoundException: *.js (No such file or directory)
 [exec]     at java.io.FileInputStream.open(Native Method)
 [exec]     at java.io.FileInputStream.<init>(FileInputStream.java:106)
 [exec]     at java.io.FileInputStream.<init>(FileInputStream.java:66)
 [exec]     at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:133)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
 [exec]     at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)

If I change the '*.js' to a certain name like 'example.js', it compressed exmaple.js into example.min.js in the same folder. So what should I do to compress all the scripts in that folder?

I used like this:

<apply executable="java" parallel="false">
        <fileset dir="${root}/js-no-console" includes="*.js"/>
        <arg line="-jar"/>
        <arg path="${root}/${tool.yuicompressor}"/>
        <srcfile/>
        <redirector alwayslog="true">
            <outputmapper type="glob" from="*.js" to="${root}/${js.min.dir}/*-min.js"/>
        </redirector>
    </apply>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM