This is an automated email from the ASF dual-hosted git repository. jdaugherty pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 18d8daf59e5e9ab6a66d811b740013fd18cf54e4 Author: James Daugherty <[email protected]> AuthorDate: Fri Oct 16 12:56:14 2026 -0400 Return the relative path of a spring script from getPathFromRoot getPathFromRoot picked m.group(m.groupCount() - 1) for whichever compiler root pattern matched. That is the file group of the three-group resource pattern, but for the single-group spring scripts pattern it is group(0), the whole match, so /app/grails-app/conf/spring/resources.groovy came back unchanged instead of as resources.groovy. Select the single group when the pattern has only one, and cover the spring script, a nested spring script and a Windows path in the model spec's data table. --- .../main/groovy/org/grails/io/support/GrailsResourceUtils.java | 4 +++- .../groovy/org/grails/io/support/GrailsResourceUtilsSpec.groovy | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grails-gradle/model/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java b/grails-gradle/model/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java index e0141a999a..2861fea39e 100644 --- a/grails-gradle/model/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java +++ b/grails-gradle/model/src/main/groovy/org/grails/io/support/GrailsResourceUtils.java @@ -856,7 +856,9 @@ public class GrailsResourceUtils { for (Pattern COMPILER_ROOT_PATTERN : COMPILER_ROOT_PATTERNS) { Matcher m = COMPILER_ROOT_PATTERN.matcher(path); if (m.find()) { - return m.group(m.groupCount() - 1); + // the spring scripts pattern captures the relative path as its only group; the resource pattern + // captures the artefact directory before it and the extension after it + return m.group(m.groupCount() == 1 ? 1 : m.groupCount() - 1); } } return null; diff --git a/grails-gradle/model/src/test/groovy/org/grails/io/support/GrailsResourceUtilsSpec.groovy b/grails-gradle/model/src/test/groovy/org/grails/io/support/GrailsResourceUtilsSpec.groovy index bbcb2b2f8c..62970a0552 100644 --- a/grails-gradle/model/src/test/groovy/org/grails/io/support/GrailsResourceUtilsSpec.groovy +++ b/grails-gradle/model/src/test/groovy/org/grails/io/support/GrailsResourceUtilsSpec.groovy @@ -62,16 +62,14 @@ class GrailsResourceUtilsSpec extends Specification { path | relativePath | directory '/app/grails-app/domain/example/Book.groovy' | 'example/Book.groovy' | 'domain' '/app/grails-app/conf/BootStrap.groovy' | 'BootStrap.groovy' | 'conf' + '/app/grails-app/conf/spring/resources.groovy' | 'resources.groovy' | 'conf' + '/app/grails-app/conf/spring/nested/beans.groovy' | 'nested/beans.groovy' | 'conf' + 'C:\\app\\grails-app\\conf\\spring\\resources.groovy' | 'resources.groovy' | 'conf' 'C:\\app\\grails-app\\domain\\example\\Book.java' | 'example\\Book.java' | 'domain' '/app/src/main/groovy/example/Book.groovy' | null | null '/app/grails-app/views/book/show.gsp' | null | null } - void 'a spring script resolves to the conf artefact directory'() { - expect: - GrailsResourceUtils.getArtefactDirectory('/app/grails-app/conf/spring/resources.groovy') == 'conf' - } - void 'domain detection distinguishes source directories and extensions'() { expect: GrailsResourceUtils.isDomainClass(new URL(location)) == expected
