From 866ae14825c8a0b46a0be65ae2475b59fcf4a27e Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Fri, 1 Nov 2024 10:59:52 +0200 Subject: [PATCH] Use fixated Kotlin compiler 2.0.20 for compiling Dokka --- .../src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts | 8 ++++++-- .../src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts | 7 +++++++ dokka-runners/dokka-gradle-plugin/gradle.properties | 1 + dokka-runners/runner-cli/gradle.properties | 1 + dokka-runners/runner-maven-plugin/gradle.properties | 1 + gradle.properties | 1 + gradle/libs.versions.toml | 3 +++ 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts b/build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts index bb6a0a6c50..565bc2456a 100644 --- a/build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts +++ b/build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts @@ -3,6 +3,7 @@ */ import dokkabuild.utils.excludeGradleEmbeddedDependencies +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.KotlinVersion plugins { @@ -12,10 +13,13 @@ plugins { } kotlin { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerVersion = libs.versions.gradlePlugin.kotlin.compiler + @Suppress("DEPRECATION", "DEPRECATION_ERROR") compilerOptions { // Must use Kotlin 1.4 to support Gradle 7 - languageVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4 - apiVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4 + languageVersion = KotlinVersion.KOTLIN_1_4 + apiVersion = KotlinVersion.KOTLIN_1_4 } } diff --git a/build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts b/build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts index 1aacaac522..3bfc2b6555 100644 --- a/build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts +++ b/build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts @@ -2,6 +2,8 @@ * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi + plugins { id("dokkabuild.java") kotlin("jvm") @@ -11,6 +13,11 @@ val rootProjectsWithoutDependencyOnDokkaCore = listOf("dokka-integration-tests") kotlin { explicitApi() + + if (dokkaBuild.kotlinLanguageLevel.isPresent) { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerVersion = libs.versions.gradlePlugin.kotlin.compiler + } compilerOptions { allWarningsAsErrors = true languageVersion = dokkaBuild.kotlinLanguageLevel diff --git a/dokka-runners/dokka-gradle-plugin/gradle.properties b/dokka-runners/dokka-gradle-plugin/gradle.properties index 3720e4947b..88c11708ca 100644 --- a/dokka-runners/dokka-gradle-plugin/gradle.properties +++ b/dokka-runners/dokka-gradle-plugin/gradle.properties @@ -9,6 +9,7 @@ version=2.0.20-SNAPSHOT org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 org.jetbrains.dokka.kotlinLanguageLevel=1.4 +kotlin.compiler.runViaBuildToolsApi=true # Gradle settings org.gradle.jvmargs=-Dfile.encoding=UTF-8 diff --git a/dokka-runners/runner-cli/gradle.properties b/dokka-runners/runner-cli/gradle.properties index d1fa567e12..bfd3e90dc6 100644 --- a/dokka-runners/runner-cli/gradle.properties +++ b/dokka-runners/runner-cli/gradle.properties @@ -9,3 +9,4 @@ version=2.0.20-SNAPSHOT org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 org.jetbrains.dokka.kotlinLanguageLevel=1.4 +kotlin.compiler.runViaBuildToolsApi=true diff --git a/dokka-runners/runner-maven-plugin/gradle.properties b/dokka-runners/runner-maven-plugin/gradle.properties index ef6f8e039b..9e62142d1f 100644 --- a/dokka-runners/runner-maven-plugin/gradle.properties +++ b/dokka-runners/runner-maven-plugin/gradle.properties @@ -7,3 +7,4 @@ version=2.0.20-SNAPSHOT org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 org.jetbrains.dokka.kotlinLanguageLevel=1.4 +kotlin.compiler.runViaBuildToolsApi=true diff --git a/gradle.properties b/gradle.properties index 8dcd75862c..8ee0816f8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,7 @@ version=2.0.20-SNAPSHOT org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 org.jetbrains.dokka.kotlinLanguageLevel=1.4 +kotlin.compiler.runViaBuildToolsApi=true # Code style kotlin.code.style=official diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b5608a6b88..9bf97de3b3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,9 @@ [versions] gradlePlugin-kotlin = "2.0.20" +# We use a different compiler version to use Kotlin Language/API version 1.4 to compile modules +# to be able to be compatible with Gradle 7. +gradlePlugin-kotlin-compiler = "2.0.20" # See: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin gradlePlugin-android = "7.1.3" gradlePlugin-dokka = "1.9.20"