From 2905c85cbe48eff1f7d45e01a15baf65b4470074 Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Mon, 23 Oct 2023 19:01:04 +0300 Subject: [PATCH] fix gradle plugin compatibility --- .../conventions/gradle-plugin.gradle.kts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts index 2df84eebc1..dbcd665dcb 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts @@ -4,6 +4,8 @@ package org.jetbrains.conventions +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { id("org.gradle.kotlin.kotlin-dsl") id("org.jetbrains.conventions.base-java") @@ -11,6 +13,25 @@ plugins { id("org.jetbrains.conventions.publishing-gradle") } +// org.gradle.kotlin.kotlin-dsl sets languageVersion and apiVersion to 1.8 by default starting from Gradle 8 +// as we want to be compatible with previous Gradle versions, we need to set it back to 1.4 +// Note: we should do it directly on tasks and not via top-level `kotlin.compilerOptions` +// because kotlin-dsl plugin declares them on task level, and so top-level config is overridden +tasks.withType().configureEach { + compilerOptions { + languageVersion.set(dokkaBuild.kotlinLanguageLevel) + apiVersion.set(dokkaBuild.kotlinLanguageLevel) + + freeCompilerArgs.addAll( + // need 1.4 support, otherwise there might be problems + // with Gradle 6.x (it's bundling Kotlin 1.4) + "-Xsuppress-version-warnings", + "-Xjsr305=strict", + "-Xskip-metadata-version-check", + ) + } +} + // Gradle will put its own version of the stdlib in the classpath, so not pull our own we will end up with // warnings like 'Runtime JAR files in the classpath should have the same version' listOf(