Skip to content

Commit f06c2b9

Browse files
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 gradle/gradle#26461 Issue gh-13408
1 parent 9e57e49 commit f06c2b9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ public class IntegrationTestPlugin implements Plugin<Project> {
5252
// ensure we don't add if no tests to avoid adding Gretty
5353
return
5454
}
55+
project.sourceSets {
56+
integrationTest {
57+
java.srcDir project.file('src/integration-test/java')
58+
resources.srcDir project.file('src/integration-test/resources')
59+
compileClasspath = project.sourceSets.main.output + project.sourceSets.test.output + project.configurations.integrationTestCompileClasspath
60+
runtimeClasspath = output + compileClasspath + project.configurations.integrationTestRuntimeClasspath
61+
}
62+
}
63+
5564
project.configurations {
5665
integrationTestCompile {
5766
extendsFrom testImplementation
@@ -69,15 +78,6 @@ public class IntegrationTestPlugin implements Plugin<Project> {
6978
}
7079
}
7180

72-
project.sourceSets {
73-
integrationTest {
74-
java.srcDir project.file('src/integration-test/java')
75-
resources.srcDir project.file('src/integration-test/resources')
76-
compileClasspath = project.sourceSets.main.output + project.sourceSets.test.output + project.configurations.integrationTestCompileClasspath
77-
runtimeClasspath = output + compileClasspath + project.configurations.integrationTestRuntimeClasspath
78-
}
79-
}
80-
8181
Task integrationTestTask = project.tasks.create("integrationTest", Test) {
8282
group = 'Verification'
8383
description = 'Runs the integration tests.'

0 commit comments

Comments
 (0)