Hi,

I would like to use the ConfigSlurper to read a groovy config file into a
ConfigObject.
The configuration file contains common and environment-specific properties
as displayed in the example below.

In order to avoid code duplication, I would like to define a common
property 'prop1'. The value of the latter depends on property 'prop2' which
is initialised later depending on the environment setting.

Regardless of the environment set, variable 'prop1' resolves to 'current
env is [:]' which is correct because 'prop2' has not yet been initialised.

Is there a way to defer 'prop1' initialisation until after 'environments'
block? Do I have any other option to solve this?

//groovy config file
prop1 = ‘current env is ’ + prop2   //common value
environments {

test {

prop2 = ‘test’

}

prod {

prop2 = ‘prod’

}

}


Thanks,
Gintas

Reply via email to