Skip to content

Instantly share code, notes, and snippets.

@zaxebo1
Forked from michalbcz/gist:2784124
Created October 14, 2020 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaxebo1/e843dc8d6f8edc483aa65a3a3705d436 to your computer and use it in GitHub Desktop.
Save zaxebo1/e843dc8d6f8edc483aa65a3a3705d436 to your computer and use it in GitHub Desktop.
groovy's AntBuilder and external ant tasks (example with Google Closure The JavaScript Compiler)
import groovy.grape.Grape;
// to explain why I am not using @Grape annotation
// see http://stackoverflow.com/questions/1641116/groovy-with-grape-and-antbuilder-classloader-problem
Grape.grab(
group: 'com.google.javascript',
module: 'closure-compiler',
version: 'r1918',
classLoader:this.class.classLoader.rootLoader /* needed because of ant.taskdef classloader */)
def ant = new AntBuilder()
// https://developers.google.com/closure/compiler/
ant.taskdef(name: 'compileJs', classname: 'com.google.javascript.jscomp.ant.CompileTask')
ant.compileJs(
compilationLevel: "whitespace", /* next values are 'simple' and 'advance' - see http://bit.ly/JfZROa */
warning: "verbose",
debug: "true",
output: /... insert path to result file here .../) {
sources(
dir: "... insert root dir where to find files in files property",
files: "first.js, second.js, insert_your_name.js")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment