From 096c87eb2f63b3420b837db9738fbae86ace4f4b Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Thu, 14 Mar 2024 22:22:55 +0100 Subject: [PATCH] fix(gradle-model): Ensure compatibility by lowering the Java target Signed-off-by: Sebastian Schuberth --- .../gradle-model/build.gradle.kts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/package-managers/gradle-model/build.gradle.kts b/plugins/package-managers/gradle-model/build.gradle.kts index 9c09b95516cc1..8c1939c1e7483 100644 --- a/plugins/package-managers/gradle-model/build.gradle.kts +++ b/plugins/package-managers/gradle-model/build.gradle.kts @@ -17,8 +17,26 @@ * License-Filename: LICENSE */ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { // Apply precompiled plugins. id("ort-kotlin-conventions") id("ort-publication-conventions") } + +// Classes that are sent to the build via custom build actions need to be targeted to the lowest supported Java version, +// which is Java 8 for Gradle 5 and above, see +// https://docs.gradle.org/current/userguide/third_party_integration.html#sec:embedding_compatibility +val gradleToolingApiLowestSupportedJavaVersion = JvmTarget.JVM_1_8 + +tasks.named("compileJava") { + targetCompatibility = gradleToolingApiLowestSupportedJavaVersion.target +} + +tasks.named("compileKotlin") { + compilerOptions { + jvmTarget = gradleToolingApiLowestSupportedJavaVersion + } +}