Here is an example of a simple preprocessor statement:
// #ifdef somedefine someLogic(); // #endif someOtherLogic();
The above statement will only include the someLogic(); call if the somedefine is defined when it’s being preprocessed. This is very similar to languages like C/C++ or C#.
This is how the above code gets filtered using the ant task:
<preprocess infile="file.js" outfile="file.processed.js" defines="somedefine,someotherdefine" />
We also wanted to use the YUICompressor to reduce the size of the script. There where a few existing Ant task implementations for this tool but we didn’t find one that was exactly as we wanted it so we wrote our of task for this as well.
Here is an example on how to compress a simple JS file:
<yuicompress infile="file.js" outfile="file.min.js" />
Both these ant tasks and future tools will be added to a google code project called js-build-tools. If you have your own ant tasks you want to contribute to this project please let us know.