is it possible to load a closure\'s code from a string (that may come from a file) in Groovy ?
This should work, not sure if it's the most elegant solution:
ClassLoader parent = getClass().getClassLoader()
GroovyClassLoader loader = new GroovyClassLoader(parent)
Class groovyClass = loader.parseClass("class ClosureHolder {def closures = [{ println 'hello world!' }]}")
def allTheClosures = groovyClass.newInstance()
allTheClosures.closures.each {
it()
}
Just put your closures inside the list when reading them in.