From 5e1b9daa6d343678b749b84848ca1b3391aaf75f Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Tue, 2 May 2023 16:25:37 +0200 Subject: [PATCH] Gradle modules build: Allow Java 20 Gradle's Kotlin scripts don't (yet) build against Java 20. Force Java 11 for build scripts. --- devtools/gradle/build-logic/build.gradle.kts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/devtools/gradle/build-logic/build.gradle.kts b/devtools/gradle/build-logic/build.gradle.kts index 4dc03934dc083..05ffa8ec29dd1 100644 --- a/devtools/gradle/build-logic/build.gradle.kts +++ b/devtools/gradle/build-logic/build.gradle.kts @@ -6,5 +6,13 @@ dependencies { implementation(plugin("com.gradle.plugin-publish", "1.2.0")) } +java { toolchain { + // this is fine, even for Java 1.x + val javaMajor = JavaVersion.current().majorVersion.toInt() + // Need to limit the Java version for Kotlin to 17, because 20 doesn't work. + // Also prefer the current version to prevent JDK downloads. + languageVersion.set(JavaLanguageVersion.of(javaMajor.coerceAtMost(17))) +} } + fun DependencyHandler.plugin(id: String, version: String) = create("$id:$id.gradle.plugin:$version")