我正在尝试添加 autoprefix-cli到我的 ANT 版本。下面是我的代码。
<target name="auto">
<apply executable="autoprefixer-cli.bat" verbose="true" force="true" failonerror="true">
<arg value="-d" /> <!-- Turn on verbose -->
<arg value="prefix" />
<arg value="*.css" />
</apply>
</target>
当我进行 ant 构建时,它会提示我未指定资源的错误。
BUILD FAILED
D:\tempTest\AntTestProject\build.xml:25: no resources specified
注意:我可以从命令行访问 autoprefix-cli,它使用 -g 标志安装,并且当我直接从命令行使用它时它也可以工作。
最佳答案
apply
任务基本上是在一批资源(文件、目录、URL 等)上循环执行 exec
任务。如果您只想运行一个命令,请改用 exec
。
但是,您可能还需要更改您的命令。来自 Ant 的 exec
任务文档:
Note that .bat files cannot in general by executed directly. One normally needs to execute the command shell executable cmd using the /c switch.
https://ant.apache.org/manual/Tasks/exec.html
所以你应该:
<exec executable="cmd" verbose="true" force="true" failonerror="true">
<arg value="/c" />
<arg value="autoprefixer-cli.bat" />
<arg value="-d" />
<arg value="prefix" />
<arg value="*.css" />
</exec>
关于java - 将 autoprefix-cli 添加到 ANT 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48547704/