From f06c2b9c62bb5e6bddd9616da8c68d306835d21b Mon Sep 17 00:00:00 2001 From: Marcus Da Coregio Date: Thu, 21 Sep 2023 15:09:58 +0100 Subject: [PATCH] Move sourceSet Declaration Before configurations Prior to this commit, with Gradle >= 8.1, we were seeing some NoClassDefFoundError related to the sun/reflect/Reflection class when running integrationTest. The error was caused because Gradle was picking the integrationTestRuntimeClasspath instead of runtimeElements, and the integrationTestRuntimeClasspath does not have the proper transitive dependencies. This commit moves the sourceSet declaration before the configurations declaration, allowing Gradle to create the named configuration automatically using the role with the allowed usage it expects, preventing integrationTestRuntimeClasspath from being selected. The related issue in Gradle is https://github.com/gradle/gradle/issues/26461 Issue gh-13408 --- .../convention/IntegrationTestPlugin.groovy | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy index 059fdfbc8b..743dec49ac 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy @@ -52,6 +52,15 @@ public class IntegrationTestPlugin implements Plugin { // ensure we don't add if no tests to avoid adding Gretty return } + project.sourceSets { + integrationTest { + java.srcDir project.file('src/integration-test/java') + resources.srcDir project.file('src/integration-test/resources') + compileClasspath = project.sourceSets.main.output + project.sourceSets.test.output + project.configurations.integrationTestCompileClasspath + runtimeClasspath = output + compileClasspath + project.configurations.integrationTestRuntimeClasspath + } + } + project.configurations { integrationTestCompile { extendsFrom testImplementation @@ -69,15 +78,6 @@ public class IntegrationTestPlugin implements Plugin { } } - project.sourceSets { - integrationTest { - java.srcDir project.file('src/integration-test/java') - resources.srcDir project.file('src/integration-test/resources') - compileClasspath = project.sourceSets.main.output + project.sourceSets.test.output + project.configurations.integrationTestCompileClasspath - runtimeClasspath = output + compileClasspath + project.configurations.integrationTestRuntimeClasspath - } - } - Task integrationTestTask = project.tasks.create("integrationTest", Test) { group = 'Verification' description = 'Runs the integration tests.'