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
This commit is contained in:
Marcus Da Coregio 2023-09-21 15:09:58 +01:00
parent 9e57e49fd6
commit f06c2b9c62
1 changed files with 9 additions and 9 deletions

View File

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