Grails: Can a config item(BuildConfig.groovy) inside environments block override a generic configuration?

227 Views Asked by At

On my BuildConfig.groovy, I have:

grails.plugin.location.plugin1 = "../plugin1"
grails.plugin.location.plugin2 = "../plugin2"

environments {
    qa2-bamboo {
        grails.plugin.location.plugin1 = "../AGP-CON-PLUG/plugin1"
        grails.plugin.location.plugin2 = "../AGP-CON-PLUG/plugin2"
    }
}

When I'm in qa2-bamboo. Is grails.plugin.location.plugin1 == "../AGP-CON-PLUG/plugin1"?

1

There are 1 best solutions below

2
On

No, that's not supported, but it probably should be for consistency. You can access the current environment value though, so you can do this with if checks

import grails.util.Environment

if (Environment.current == Environment.DEVELOPMENT || Environment.isDevelopmentMode()) {
   ...
}

or a switch block:

switch (Environment.current) {
   case Environment.DEVELOPMENT:
      ...
      break
   case ...
   default:
      ...
}