I have an Ant project that uses a bit of Coffee Script. I would like Ant to compile all of the coffee instead of having another build step to compile it. The coffee command line script that I want to use, that compiles all coffee files into synonomous js files (site.coffee compiles to site.js, app.coffee compiles to app.js):
coffee -c ./js/*.coffee
I created an Ant task that I assumed would run the same command, but am getting an error:
<target name="compilecoffee" description="Compiles coffeescript files">
<exec executable="coffee">
<arg value="-c ${env.WORKSPACE}js/*.coffee" />
</exec>
</target>
Now when I run ant compilecoffee -Denv.WORKSPACE=./ I get the following error from Coffee:
Buildfile: /Users/dave/Workspace/ColdFusion/Mura-Themes/e123-1/build.xml
compilecoffee:
[exec]
[exec] node.js:116
[exec] throw e; // process.nextTick error, or 'error' event on first tick
[exec] ^
[exec] Error: unrecognized option: -c ./js/3_site.coffee
[exec] at OptionParser.parse (/Users/dave/local/lib/node/.npm/coffee-script/1.1.1/package/lib/optparse.js:34:17)
[exec] at /Users/dave/local/lib/node/.npm/coffee-script/1.1.1/package/lib/command.js:245:29
[exec] at Object.run (/Users/dave/local/lib/node/.npm/coffee-script/1.1.1/package/lib/command.js:24:5)
[exec] at Object.<anonymous> (/Users/dave/local/lib/node/.npm/coffee-script/1.1.1/package/bin/coffee:7:27)
[exec] at Module._compile (module.js:373:26)
[exec] at Object..js (module.js:379:10)
[exec] at Module.load (module.js:305:31)
[exec] at Function._load (module.js:271:10)
[exec] at Array.<anonymous> (module.js:392:10)
[exec] at EventEmitter._tickCallback (node.js:108:26)
[exec] Result: 1
If I run, what I thought was, the coffee equivelant directly at the command line (coffee -c ./js/*.coffee) I get no errors and everything works as expected. Am I using the exec target wrong?
try =
or use one arg value=… for every part of the command
coffee executable has to be on path or use =
EDIT
as Dominic pointed out, the ‘*’ won’t be expanded, so you should use apply =
see Ant Manual apply task f.e. you may use parallel=”true”, means run the command only once, appending all files as arguments, if possible with coffee, to speed it up.