groovy Use ConfigSluper (instead of property files) ConfigSlurper using string, number, boolean or list


In the file myConfig.groovy is the following content.

message = 'Hello World!'
aList=["apples", "grapes", "oranges"]

Then in your main script you create a ConfigSlurper for your myConfig.groovy file which is really just another groovy script.

config = new ConfigSlurper().parse(new File('/path/to/myConfig.groovy').toURL())

Then to use the items from the config you can just refer to them.

assert 'Hello World!' == config.message
assert 42 == config.aNumber
assert false == config.aBoolean
assert ["apples", "grapes", "oranges"] == config.aList