Last active
June 23, 2016 08:22
-
-
Save antonmry/a1ea9fe4962d934a4434bab939cd60a0 to your computer and use it in GitHub Desktop.
Load groovy properties-like file in another groovy file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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