I am using closure compiler jar for minification in r.js optimization in windows environment.
While running this task using ANT exec, getting illegal character error but while running same task using .bat file it working fine.
ANT exec task
<target name="do-optimization" description="It will do optimization using r.js.">
<exec dir="." executable="java" failonerror="true">
<arg value="-jar" />
<arg path="${src.dir}/r-js/lib/rhino/js.jar" />
<arg path="${src.dir}/r-js/lib/closure/compiler.jar" />
<arg path="${src.dir}/r-js/dist/r.js" />
<arg value="-o"/>
<arg path="${src.dir}/r-js/build.js" />
</exec>
</target>
console output
do-optimization:
[exec] js: "C:\workspace\test\ui\r-js\lib\closure\compiler.jar", line 2: illegal character
[exec] js: ╝MOC ♦ META-INF/■╩ PK♥♦
[exec] js: ^
[exec] js: "C:\workspace\test\ui\r-js\lib\closure\compiler.jar", line 1: Compilation produced 1 syntax errors.
[exec]
BUILD FAILED
optimize.bat
java -classpath "r-js\lib\rhino\js.jar";"r-js\lib\closure\compiler.jar" org.mozilla.javascript.tools.shell.Main r-js/dist/r.js -o build.js
It doesn't seem that the Ant script is calling
java
the same way as the batch file. Theexec
task is calling the following command:which is clearly different than the one in the .bat file, i.e. the jars are not being added to the classpath properly.
In Ant, you can simply use the
java
task to run a Java class. Try using the following: