ant + yuicompressor path error

偶尔善良 提交于 2021-02-07 12:47:29

问题


I've got a file in C:\Bin\test.js that I would like to compress and have renamed test-min.js

my ant build.xml looks like this:

<property name="temp.dir" value="C:\Bin\"/>

<apply executable="java" parallel="false" dest="${temp.dir}">
   <fileset dir="${temp.dir}" includes="test.js"/>
   <arg line="-jar"/>
   <arg path="${yui.dir}"/>
   <srcfile/>
   <arg line="-o"/>
   <mapper type="glob" from="*.js" to="*-min.js"/>
   <targetfile/>
</apply>

I get the following Java error:

[apply] java.io.FileNotFoundException: Bintest-min.js:\Bin\test.js (The filename, directory name, or volume label syntax is incorrect)

I've tried every combination of pathing and filenames I could come up with. What am I missing? It looks like it's stripping out C:\ and the second \

And I know YUI works because I can do it manually from the command line.


回答1:


I ran into this problem after upgrading to yuicompressor 2.4.8

There is a knows bug in 2.4.8 where it does not handle the quoted paths generated by ant.

Going back to 2.4.7 fixed the issue for me. You can download 2.4.7 here: https://github.com/yui/yuicompressor/downloads

You can find discussion of the issue here: http://www.yuiblog.com/blog/2013/05/16/yuicompressor-2-4-8-released/

"New version 2.4.8 fails to parse Windows filename in quotes correctly. 2.4.7 works fine. Eg, command java -jar yuicompressor-2.4.8.jar “d:\work\common_source.js” –charset utf-8 –disableoptimizations -v -o “d:\work\common.js” gives error java.io.FileNotFoundException: workcommon.js:\work\coomon_source.js (The filename, directory name, or volume label syntax is incorrect). Unfortunately, this renders it entirely unusable."

And the YUI Compressor defect is here: https://github.com/yui/yuicompressor/issues/78




回答2:


I've ran into these sort of problems in the past, try /Bin



来源:https://stackoverflow.com/questions/17932315/ant-yuicompressor-path-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!