This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit b281fe6abfd1967d216398703378403b63e5bd90
Merge: 093d11297e 93bc170840
Author: James Daugherty <[email protected]>
AuthorDate: Tue Oct 13 11:25:44 2026 +0100

    Merge branch '7.2.x' into 8.0.x

 .../groovy/org/grails/config/NavigableMap.groovy   |  49 ---
 .../groovy/grails/config/NavigableMapSpec.groovy   |  21 +
 .../grails/config/SpringProfileExcludeSpec.groovy  | 173 --------
 .../config/yaml/YamlPropertySourceLoader.java      |  66 ++-
 .../grails/boot/GrailsAppYamlProfileSpec.groovy    | 100 +++++
 .../config/PropertySourcesConfigReloadSpec.groovy  | 220 ++++++++++
 .../config/YamlPropertySourceLoaderSpec.groovy     |  23 +
 .../org/grails/config/YamlSpringProfileSpec.groovy | 463 +++++++++++++++++++++
 .../GroovyConfigPropertySourceLoaderSpec.groovy    |  50 +++
 grails-doc/src/en/guide/conf/config.adoc           |  31 ++
 .../externalconfig/ExternalConfigSpec.groovy       |  31 ++
 11 files changed, 1003 insertions(+), 224 deletions(-)

diff --cc 
grails-core/src/test/groovy/org/grails/core/cfg/GroovyConfigPropertySourceLoaderSpec.groovy
index 350c3811de,40c936e291..3ba014338c
--- 
a/grails-core/src/test/groovy/org/grails/core/cfg/GroovyConfigPropertySourceLoaderSpec.groovy
+++ 
b/grails-core/src/test/groovy/org/grails/core/cfg/GroovyConfigPropertySourceLoaderSpec.groovy
@@@ -35,34 -37,50 +41,78 @@@ class GroovyConfigPropertySourceLoaderS
          resetEnvironment()
      }
  
 +    void "a list of objects in application.groovy binds to configuration 
properties element by element"() {
 +        given:
 +        File file = File.createTempFile('list-binding-application', '.groovy')
 +        file.deleteOnExit()
 +        file.text = '''
 +            app {
 +                items = [[name: 'one', tags: ['x', 'y']], [name: 'two']]
 +                rows = [[[name: 'a'], [name: 'b']], [[name: 'c']]]
 +                names = ['p', '${EXAMPLE_NAME:q}']
 +            }
 +        '''.stripIndent()
 +        def environment = new StandardEnvironment()
 +        environment.propertySources.addFirst(new 
GroovyConfigPropertySourceLoader().load(file.name, new 
FileSystemResource(file)).first())
 +        ConfigurationPropertySources.attach(environment)
 +
 +        when:
 +        ListBindingProperties bound = Binder.get(environment).bind('app', 
Bindable.of(ListBindingProperties)).get()
 +
 +        then: 'a list of objects, a list inside one of them, and a list of 
lists of objects'
 +        bound.items*.getClass() == [ListBindingItem, ListBindingItem]
 +        bound.items*.name == ['one', 'two']
 +        bound.items[0].tags == ['x', 'y']
 +        bound.rows*.collect { it.name } == [['a', 'b'], ['c']]
 +
 +        and: 'placeholders in a list of plain values are resolved'
 +        bound.names == ['p', 'q']
 +    }
 +
+     void cleanup() {
+         Environment.reset()
+     }
+ 
+     void '#fileName retains #profileKey as data and selects Grails 
environment blocks'() {
+         given:
+         environment = Environment.TEST
+         Environment.reset()
+         System.setProperty('spring.profiles.active', 'dev')
+         File applicationFile = new File(configDirectory, 'application.groovy')
+         applicationFile.text = "sample.message = 'application'"
+         new File(configDirectory, fileName).text = """
+ ${profileSetting}
+ sample.message = 'default'
+ sample.retained = 'loaded'
+ environments {
+     test {
+         sample.message = 'test'
+     }
+     production {
+         sample.message = 'production'
+         sample.productionOnly = 'production'
+     }
+ }
+ """
+ 
+         when:
+         def sources = new 
GroovyConfigPropertySourceLoader().load('application.groovy', new 
FileSystemResource(applicationFile))
+         def config = new PropertySourcesConfig(sources.first())
+ 
+         then:
+         config.getProperty(profileKey) == 'prod'
+         config.getProperty('sample.retained') == 'loaded'
+         config.getProperty('sample.message') == 'test'
+         config.getProperty('sample.productionOnly') == null
+ 
+         where:
+         fileName             | profileKey                          | 
profileSetting
+         'application.groovy' | 'spring.profiles'                   | 
"spring.profiles = 'prod'"
+         'application.groovy' | 'spring.config.activate.on-profile' | 
"spring.config.activate.'on-profile' = 'prod'"
+         'runtime.groovy'     | 'spring.profiles'                   | 
"spring.profiles = 'prod'"
+         'runtime.groovy'     | 'spring.config.activate.on-profile' | 
"spring.config.activate.'on-profile' = 'prod'"
+     }
+ 
      void "test loading multiple configuration files"() {
          setup:
          Resource inputStreamWithDsl = new 
FileSystemResource(getClass().getClassLoader().getResource("test-application.groovy").getFile())

Reply via email to