Skip to content

Commit a797fd8

Browse files
committed
Set source/target compatibility on JavaPluginExtension
So plugins like Groovy and Shadow can read it from there.
1 parent 3d61b7a commit a797fd8

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
`kotlin-dsl`
35
}
6+
7+
java {
8+
sourceCompatibility = JavaVersion.VERSION_17
9+
targetCompatibility = JavaVersion.VERSION_17
10+
}
11+
12+
kotlin {
13+
compilerOptions.jvmTarget = JvmTarget.JVM_17
14+
}

gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ tasks {
253253
}
254254

255255
afterEvaluate {
256+
java {
257+
// For Groovy and Shadow plugins
258+
sourceCompatibility = extension.mainJavaVersion.get()
259+
targetCompatibility = extension.mainJavaVersion.get()
260+
}
256261
pluginManager.withPlugin("groovy") {
257-
tasks.named<GroovyCompile>("compileGroovy").configure {
258-
// Groovy compiler does not support the --release flag.
259-
sourceCompatibility = extension.mainJavaVersion.get().majorVersion
260-
targetCompatibility = extension.mainJavaVersion.get().majorVersion
261-
}
262-
tasks.named<GroovyCompile>("compileTestGroovy").configure {
262+
tasks.withType<GroovyCompile>().named { it.startsWith("compileTest") }.configureEach {
263263
// Groovy compiler does not support the --release flag.
264264
sourceCompatibility = extension.testJavaVersion.get().majorVersion
265265
targetCompatibility = extension.testJavaVersion.get().majorVersion

0 commit comments

Comments
 (0)