Skip to content

Instantly share code, notes, and snippets.

@uehaj
Created March 28, 2012 10:12
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 uehaj/2225199 to your computer and use it in GitHub Desktop.
Save uehaj/2225199 to your computer and use it in GitHub Desktop.
groovy script invoker with statically type check without annotation.
#!/usr/bin/env groovy # -*-groovy-*-
import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer
import org.codehaus.groovy.control.CompilerConfiguration
import groovy.transform.TypeChecked
def configuration = new CompilerConfiguration()
configuration.addCompilationCustomizers(new ASTTransformationCustomizer(TypeChecked))
def binding = new Binding()
binding.setVariable("args", args.tail())
def shell = new GroovyShell(binding, configuration)
shell.evaluate(new File(args.head()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment