Skip to content

Instantly share code, notes, and snippets.

@antonmry
Last active June 23, 2016 08:22
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 antonmry/a1ea9fe4962d934a4434bab939cd60a0 to your computer and use it in GitHub Desktop.
Save antonmry/a1ea9fe4962d934a4434bab939cd60a0 to your computer and use it in GitHub Desktop.
Load groovy properties-like file in another groovy file
import groovy.lang.GroovyClassLoader
// http://docs.groovy-lang.org/latest/html/documentation/index.html#_integrating_groovy_in_a_java_application
def gcl = new GroovyClassLoader()
def clazz = gcl.parseClass(new File("./template.groovy"))
assert clazz.name == 'Env'
def o = clazz.newInstance()
o.doIt()
println o.test
class Env {
String test ="It works"
void doIt() {
println "ok" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment