Skip to content

Commit c8ddc84

Browse files
committed
Support a grails-app/conf/runtime.groovy configuration file. Fixes #10131
1 parent 44d3ce0 commit c8ddc84

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

grails-core/src/main/groovy/org/grails/core/cfg/GroovyConfigPropertySourceLoader.groovy

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import grails.util.BuildSettings
1919
import grails.util.Environment
2020
import grails.util.Metadata
2121
import groovy.transform.CompileStatic
22-
import groovy.util.logging.Commons
22+
import groovy.util.logging.Slf4j
2323
import org.grails.config.NavigableMap
2424
import org.grails.config.NavigableMapPropertySource
2525
import 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
3939
class 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

Comments
 (0)