浏览代码

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
Marcus Da Coregio 1 年之前
父节点
当前提交
f06c2b9c62
共有 1 个文件被更改,包括 9 次插入9 次删除
  1. 9 9
      buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy

+ 9 - 9
buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy

@@ -52,6 +52,15 @@ public class IntegrationTestPlugin implements Plugin<Project> {
 			// 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> {
 			}
 		}
 
-		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.'