Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SemanticdbGradlePlugin extends Plugin[Project] {
project
.getTasks()
.withType(classOf[JavaCompile])
.all { task =>
.configureEach { task =>
// If we run on JDK 17, we need to add special flags to the JVM
// to allow access to the compiler.

Expand Down
33 changes: 33 additions & 0 deletions tests/buildTools/src/test/scala/tests/GradleBuildToolSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,37 @@ abstract class GradleBuildToolSuite(gradle: Tool.Gradle)
// NOTE(olafur): no packages because we use more modern APIs.
)

// Regression test: projects that lazily register custom source sets (e.g. intTest)
// with a Java toolchain would fail because the eager `.all {}` API in the plugin
// caused the javaCompiler property to be finalized before Gradle finished
// configuring the task.
checkGradleBuild(
"lazy-sourceset-with-toolchain",
s"""|/build.gradle
|plugins {
| id 'java'
|}
|java {
| toolchain {
| languageVersion = JavaLanguageVersion.of(11)
| }
|}
|sourceSets {
| intTest {
| compileClasspath += sourceSets.main.output
| runtimeClasspath += sourceSets.main.output
| }
|}
|configurations {
| intTestImplementation.extendsFrom implementation
|}
|/src/main/java/Example.java
|public class Example {}
|/src/intTest/java/ExampleIntTest.java
|public class ExampleIntTest {}
|""".stripMargin,
expectedSemanticdbFiles = 1,
gradleVersions = List(Gradle8, Gradle7)
)

}