To invoke a script, we have to use the exec tag and specify at least the param “executable“, which indicates the location of the script to execute, then by setting the parameter “output” the result returned from the script will be redirect to the specified file. Finally, to avoid undesired output in the file, such debug information and errors, we have to specify also a file which will receive this type of data by using the “error” parameter.
Since, paths to scripts and other files can be very long, we can create custom variables to hold these information and then reusing them in our script invocations. This is as simple as use the “property” tag and specify a “name” and a “value” attributes.
The following is an example of how a build.xml will looks like:
The build.xml above will first gathering all the necessary Closure files (dependencies) and then will compile the resulting js using a WHITESPACE_ONLY compilation. The result will be printed to the file “ant-generation.js” and the debug to “closure-compiler.log”.
To run the Ant process: right click on the build.xml and choose Run as Ant Build. This procedure can be also configured in order to execute all the task each time a file in the project is saved, but it’s not a great idea because the process can takes several seconds to complete.
If you want to learn more about Ant (I have to learn a lot too, since I never used it before :P), check the reference here: http://ant.apache.org