@@ -19,7 +19,7 @@ import grails.util.BuildSettings
1919import grails.util.Environment
2020import grails.util.Metadata
2121import groovy.transform.CompileStatic
22- import groovy.util.logging.Commons
22+ import groovy.util.logging.Slf4j
2323import org.grails.config.NavigableMap
2424import org.grails.config.NavigableMapPropertySource
2525import org.grails.core.exceptions.GrailsConfigurationException
@@ -35,7 +35,7 @@ import org.springframework.core.io.Resource
3535 * @since 3.0
3636 */
3737@CompileStatic
38- @Commons
38+ @Slf4j
3939class GroovyConfigPropertySourceLoader implements PropertySourceLoader {
4040
4141 final String [] fileExtensions = [' groovy' ] as String []
@@ -46,8 +46,9 @@ class GroovyConfigPropertySourceLoader implements PropertySourceLoader {
4646 }
4747
4848 PropertySource<?> load (String name , Resource resource , String profile , List<String > filteredKeys ) throws IOException {
49- def env = Environment . current. name
50- if (profile == null || env == profile) {
49+ // since ConfigSlurper is already environment aware, don't load it twice
50+ if (profile == null ) {
51+ def env = Environment . current. name
5152
5253 if (resource. exists()) {
5354 ConfigSlurper configSlurper = env ? new ConfigSlurper (env) : new ConfigSlurper ()
@@ -66,6 +67,13 @@ class GroovyConfigPropertySourceLoader implements PropertySourceLoader {
6667
6768 def propertySource = new NavigableMap ()
6869 propertySource. merge(configObject, false )
70+
71+ Resource runtimeResource = resource. createRelative( resource. filename. replace(' application' , ' runtime' ) )
72+ if (runtimeResource. exists()) {
73+ def runtimeConfig = configSlurper. parse( runtimeResource. getURL() )
74+ propertySource. merge(runtimeConfig, false )
75+ }
76+
6977 return new NavigableMapPropertySource (name, propertySource)
7078 } catch (Throwable e) {
7179 log. error(" Unable to load $resource . filename : $e. message " , e)
0 commit comments