Last active
August 29, 2015 14:15
-
-
Save Hubbitus/42a00248e3f0012d6ebf to your computer and use it in GitHub Desktop.
Modularizing groovy config workaround
This file contains hidden or 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
// 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