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

jdaugherty pushed a commit to branch fix/split-cli-dependencies
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit e1bac4aa6170850d87303cf9269a1b3a3f2ba642
Author: James Daugherty <[email protected]>
AuthorDate: Thu Jul 9 15:33:10 2026 -0400

    Adjust test configuration
---
 .../commands/GrailsCliArtifactGradlePlugin.groovy  | 25 ++++++++--------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git 
a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/commands/GrailsCliArtifactGradlePlugin.groovy
 
b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/commands/GrailsCliArtifactGradlePlugin.groovy
index fb2c0c8cca..c12feea52c 100644
--- 
a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/commands/GrailsCliArtifactGradlePlugin.groovy
+++ 
b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/commands/GrailsCliArtifactGradlePlugin.groovy
@@ -152,22 +152,15 @@ abstract class GrailsCliArtifactGradlePlugin implements 
Plugin<Project> {
             configureDependencyMapping(project, details, cliRuntimeClasspath)
         }
 
-        // the plugin's tests exercise the cli classes through their public API
-        SourceSet testSourceSet = sourceSets.findByName('test')
-        if (testSourceSet != null) {
-            testSourceSet.compileClasspath += cliSourceSet.output
-            testSourceSet.runtimeClasspath += cliSourceSet.output
-            project.configurations.named('testImplementation').configure { 
Configuration it ->
-                it.extendsFrom(project.configurations.getByName('cliApi'), 
project.configurations.getByName('cliImplementation'))
-            }
-        }
-        SourceSet integrationTestSourceSet = 
sourceSets.findByName('integrationTest')
-        if (integrationTestSourceSet != null) {
-            integrationTestSourceSet.compileClasspath += cliSourceSet.output
-            integrationTestSourceSet.runtimeClasspath += cliSourceSet.output
-            
project.configurations.named('integrationTestImplementation').configure { 
Configuration it ->
-                it.extendsFrom(project.configurations.getByName('cliApi'), 
project.configurations.getByName('cliImplementation'))
-            }
+        // the plugin's tests exercise the cli classes through their public 
API: the cli output
+        // and the cli dependency buckets flow into the test configurations 
(dependency-based, so
+        // the wiring is immune to when test tasks snapshot their source set 
classpaths)
+        for (String testConfiguration : ['testImplementation', 
'integrationTestImplementation']) {
+            project.configurations.matching { Configuration it -> it.name == 
testConfiguration }
+                    .configureEach { Configuration it ->
+                        project.dependencies.add(it.name, cliSourceSet.output)
+                        
it.extendsFrom(project.configurations.getByName('cliApi'), 
project.configurations.getByName('cliImplementation'))
+                    }
         }
 
         project.tasks.named(cliSourceSet.jarTaskName, Jar).configure { Jar jar 
->

Reply via email to