While invoking an Ant taskdef, why does this particular case require a closure?
I’m using the Closure Compiler ant task, example usage (from http://code.google.com/p/closure-compiler/wiki/BuildingWithAnt):
<taskdef name=“jscomp” classname=“com.google.javascript.jscomp.ant.CompileTask”
classpath="…/build/compiler.jar"/> <target name=“compile”>
<jscomp compilationLevel=“simple” warning=“verbose”
debug=“false” output=“output/file.js”>
<sources dir="${basedir}/other">
<file name=“stacktrace.js”/>
</sources>
</jscomp> </target>
Converting to Gradle:
task minify << {
description = 'minify JS file'
project.ant {
ant.taskdef(name: 'jscomp',
classname: 'com.google.javascript.jscomp.ant.CompileTask',
classpath: configurations.js.asPath)
jscomp(compilationLevel: 'simple', warning: 'quiet', debug: 'false', output: minifiedFilePath) {
sources(dir: srcDir) {
//file(name: 'stacktrace.js') does not work. Shouldn't it?
file(name: 'stacktrace.js'){} // Why do I need the curly braces here?
}
}
}
}
I’ve used other ant tasks and the structure of closures made sense. But, I beat my head against a wall, a desk and my monitor for a couple hours to figure this one out, so I was just curious to know why.