소스 검색

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.'