Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Modularizing groovy config workaround
// For structured comment of http://naleid.com/blog/2009/07/30/modularizing-groovy-config-files-with-a-dash-of-meta-programming
// SecurityConfigPlain.groovy
security {
includeScript( SecurityDefaults )
active = true
password = 'redefined'
}
// and then use (OtherClass.groovy):
def configObjectPlain = new ConfigSlurper().parse(
"""
class SecurityConfig extends ComposedConfigScript {
def run() { // normal contents of a config file go in here
${new File('SecurityConfigPlain.groovy').text}
}
}
"""
)
println configObjectPlain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment