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 + } +}