Skip to content
Merged
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
35 changes: 26 additions & 9 deletions tests/buildTools/src/test/scala/tests/GradleBuildToolSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class Gradle_8_BuildToolSuite extends GradleBuildToolSuite(Gradle8)
class Gradle_7_BuildToolSuite extends GradleBuildToolSuite(Gradle7)
class Gradle_6_BuildToolSuite extends GradleBuildToolSuite(Gradle6)
class Gradle_5_BuildToolSuite extends GradleBuildToolSuite(Gradle5)
class Gradle_3_BuildToolSuite extends GradleBuildToolSuite(Gradle3)
class Gradle_2_BuildToolSuite extends GradleBuildToolSuite(Gradle2)

abstract class GradleBuildToolSuite(gradle: Tool.Gradle)
extends GradleBuildToolSuiteBase(gradle) {
Expand Down Expand Up @@ -497,18 +495,37 @@ abstract class GradleBuildToolSuite(gradle: Tool.Gradle)
// )
// }

// 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(
"legacy",
"lazy-sourceset-with-toolchain",
s"""|/build.gradle
|apply plugin: 'java'
|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/test/java/ExampleSuite.java
|public class ExampleSuite {}
|/src/intTest/java/ExampleIntTest.java
|public class ExampleIntTest {}
|""".stripMargin,
expectedSemanticdbFiles = 2,
gradleVersions = List(Gradle3, Gradle2)
// NOTE(olafur): no packages because we use more modern APIs.
expectedSemanticdbFiles = 1,
gradleVersions = List(Gradle8, Gradle7)
)

}
4 changes: 1 addition & 3 deletions tests/buildTools/src/test/scala/tests/Tool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ object Tool {
// See https://docs.gradle.org/current/userguide/compatibility.html
sealed abstract class Gradle(version: String, support: JVMSupport)
extends Tool("gradle", version, support)
case object Gradle8 extends Gradle("8.7", atMostJava(21))
case object Gradle8 extends Gradle("8.10", atMostJava(21))
case object Gradle7 extends Gradle("7.6.3", atMostJava(17))
case object Gradle6 extends Gradle("6.8.3", atMostJava(11))
case object Gradle5 extends Gradle("5.6.4", atMostJava(11))
case object Gradle3 extends Gradle("3.3", atMostJava(8))
case object Gradle2 extends Gradle("2.14.1", atMostJava(8))

sealed abstract class SBT(version: String, support: JVMSupport)
extends Tool("sbt", version, support)
Expand Down
Loading