A Groovy script file can be compiled to a Java .class file using the command groovyc script-name.groovy. If there are loose statements in the script, this .class file will contain a main method, so it can be executed as a Java application using the command java script-name . The contents of the main method will be discussed later. The classpath must contain the groovy*.jar and asm*.jar files from the Groovy lib directory.
There’s even a custom Ant task to do this! The class is org.codehaus.groovy.ant.Groovyc.