So here is how it works.
First you need to define the jscomp task-
This creates a task named jscomp using compiler jar and class named CompileTask located in the Closure-Compiler directory.
Next we need to create our target. I simply named mine “compile”. Nested inside the target I call the jscomp task passing it the attributes. This is simple, but was tricky as some of the values passed to the attributes differ from the documented values.
For example, the compilation level will accept the following values “WHITESPACE_ONLY”,”SIMPLE_OPTIMIZATIONS”,”ADVANCED_OPTIMIZATIONS” via command line, but with the class the attribute values are “whitespace”,”simple”,”advanced”.
Finally nested inside of the jscomp task, we define our “externs” and “source” files. In my case I didn’t really need to define any externs, but for a demonstration purposes, I have provided it the code.