Skip to content

Instantly share code, notes, and snippets.

@Hubbitus
Last active August 29, 2015 14:15
Show Gist options
  • Save Hubbitus/42a00248e3f0012d6ebf to your computer and use it in GitHub Desktop.
Save Hubbitus/42a00248e3f0012d6ebf to your computer and use it in GitHub Desktop.
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