Skip to content

Commit b7071da

Browse files
committed
Use fixated Kotlin compiler 2.0.20 for compiling Dokka
1 parent b449849 commit b7071da

File tree

13 files changed

+50
-34
lines changed

13 files changed

+50
-34
lines changed

build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@
22
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
import dokkabuild.utils.configureGradleKotlinCompatibility
56
import dokkabuild.utils.excludeGradleEmbeddedDependencies
6-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
77

88
plugins {
99
id("org.gradle.kotlin.kotlin-dsl")
1010
id("dokkabuild.java")
1111
id("dokkabuild.publish-gradle-plugin")
1212
}
1313

14-
kotlin {
15-
compilerOptions {
16-
// Must use Kotlin 1.4 to support Gradle 7
17-
languageVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4
18-
apiVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4
19-
}
20-
}
14+
configureGradleKotlinCompatibility()
2115

2216
tasks.compileKotlin {
2317
compilerOptions {

build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
import dokkabuild.utils.configureGradleKotlinCompatibility
6+
57
plugins {
68
id("dokkabuild.java")
79
kotlin("jvm")
810
}
911

1012
val rootProjectsWithoutDependencyOnDokkaCore = listOf("dokka-integration-tests")
1113

14+
configureGradleKotlinCompatibility()
15+
1216
kotlin {
1317
explicitApi()
18+
1419
compilerOptions {
1520
allWarningsAsErrors = true
16-
languageVersion = dokkaBuild.kotlinLanguageLevel
17-
apiVersion = dokkaBuild.kotlinLanguageLevel
1821

1922
// These projects know nothing about the `@InternalDokkaApi` annotation, so the Kotlin compiler
2023
// will complain about an unresolved opt-in requirement marker and fail the build if it's not excluded.
@@ -24,13 +27,5 @@ kotlin {
2427
"org.jetbrains.dokka.InternalDokkaApi"
2528
)
2629
}
27-
28-
freeCompilerArgs.addAll(
29-
// need 1.4 support, otherwise there might be problems
30-
// with Gradle 6.x (it's bundling Kotlin 1.4)
31-
"-Xsuppress-version-warnings",
32-
"-Xjsr305=strict",
33-
"-Xskip-metadata-version-check",
34-
)
3530
}
3631
}

build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ abstract class DokkaBuildProperties @Inject constructor(
5959
dokkaProperty("javaToolchain.testLauncher", JavaLanguageVersion::of)
6060
.orElse(mainJavaVersion)
6161

62-
/**
63-
* The Kotlin language level that Dokka artifacts are compiled to support.
64-
*
65-
* Updating the language level is a breaking change.
66-
*/
67-
val kotlinLanguageLevel: Provider<KotlinVersion> =
68-
dokkaProperty("kotlinLanguageLevel", KotlinVersion::fromVersion)
62+
/** Indicates whether Kotlin compatibility with older Gradle versions should be enforced */
63+
val enforceGradleKotlinCompatibility: Provider<Boolean> =
64+
dokkaProperty("enforceGradleKotlinCompatibility", String::toBoolean)
65+
.orElse(true)
6966

7067
/** Allows skipping running of integration tests */
7168
val integrationTestSkip: Provider<Boolean> =
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2014-2025 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package dokkabuild.utils
6+
7+
import org.gradle.api.Project
8+
import org.gradle.kotlin.dsl.dokkaBuild
9+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
10+
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
11+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
12+
13+
// We must use Kotlin language/api version 1.4 (DEPRECATED) to support Gradle 7,
14+
// and to do that we need to use old Kotlin version, which has support for such an old Kotlin version (e.g., 2.0.20)
15+
fun Project.configureGradleKotlinCompatibility() {
16+
if (!dokkaBuild.enforceGradleKotlinCompatibility.get()) return
17+
18+
extensions.configure<KotlinJvmProjectExtension>("kotlin") {
19+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
20+
compilerVersion.set("2.0.20")
21+
coreLibrariesVersion = "2.0.20"
22+
compilerOptions {
23+
languageVersion.set(KotlinVersion.fromVersion("1.4"))
24+
apiVersion.set(KotlinVersion.fromVersion("1.4"))
25+
freeCompilerArgs.add("-Xsuppress-version-warnings")
26+
}
27+
}
28+
}

dokka-integration-tests/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ version=2.0.20-SNAPSHOT
1010
org.jetbrains.dokka.javaToolchain.mainCompiler=8
1111
org.jetbrains.dokka.javaToolchain.testLauncher=8
1212
org.jetbrains.dokka.integration_test.parallelism=2
13+
org.jetbrains.dokka.enforceGradleKotlinCompatibility=false
1314

1415
# !!! ATTENTION: do not commit this !!!
1516
# Uncomment next line to skip running Dokka integration tests

dokka-integration-tests/gradle/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222

2323
api(libs.jsoup)
2424

25-
api(libs.kotlin.test)
25+
api(kotlin("test-junit5"))
2626
api(libs.junit.jupiterApi)
2727
api(libs.junit.jupiterParams)
2828
api(libs.kotest.assertionsCore)

dokka-integration-tests/maven/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
dependencies {
2020
api(projects.utilities)
2121

22-
api(libs.kotlin.test)
22+
api(kotlin("test-junit5"))
2323
api(libs.junit.jupiterApi)
2424

2525
val dokkaVersion = project.version.toString()

dokka-runners/dokka-gradle-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ testing.suites {
153153
implementation(libs.kotlinxSerialization.json)
154154

155155
//region classic-plugin dependencies - delete these when src/classicMain is removed
156-
implementation(libs.kotlin.test)
156+
implementation(project.dependencies.kotlin("test").toString())
157157
implementation(libs.gradlePlugin.kotlin)
158158
implementation(libs.gradlePlugin.kotlin.klibCommonizerApi)
159159
implementation(libs.gradlePlugin.android)

dokka-runners/dokka-gradle-plugin/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version=2.0.20-SNAPSHOT
88

99
org.jetbrains.dokka.javaToolchain.mainCompiler=8
1010
org.jetbrains.dokka.javaToolchain.testLauncher=8
11-
org.jetbrains.dokka.kotlinLanguageLevel=1.4
11+
kotlin.compiler.runViaBuildToolsApi=true
1212

1313
# Gradle settings
1414
org.gradle.jvmargs=-Dfile.encoding=UTF-8

dokka-runners/runner-cli/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ version=2.0.20-SNAPSHOT
88

99
org.jetbrains.dokka.javaToolchain.mainCompiler=8
1010
org.jetbrains.dokka.javaToolchain.testLauncher=8
11-
org.jetbrains.dokka.kotlinLanguageLevel=1.4
11+
kotlin.compiler.runViaBuildToolsApi=true

dokka-runners/runner-maven-plugin/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ version=2.0.20-SNAPSHOT
66

77
org.jetbrains.dokka.javaToolchain.mainCompiler=8
88
org.jetbrains.dokka.javaToolchain.testLauncher=8
9-
org.jetbrains.dokka.kotlinLanguageLevel=1.4
9+
kotlin.compiler.runViaBuildToolsApi=true

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version=2.0.20-SNAPSHOT
88

99
org.jetbrains.dokka.javaToolchain.mainCompiler=8
1010
org.jetbrains.dokka.javaToolchain.testLauncher=8
11-
org.jetbrains.dokka.kotlinLanguageLevel=1.4
11+
kotlin.compiler.runViaBuildToolsApi=true
1212

1313
# Code style
1414
kotlin.code.style=official

gradle/libs.versions.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[versions]
22

3+
# We use a different compiler version to compile modules and Gradle Plugin
4+
# to be able to use Kotlin Language/API version 1.4 to be compatible with Gradle 7.
5+
# The logic leaves in build-logic/src/main/kotlin/dokkabuild/utils/gradleKotlinCompatibility.kt
36
gradlePlugin-kotlin = "2.0.20"
47
# See: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin
58
gradlePlugin-android = "7.1.3"
@@ -142,8 +145,6 @@ kotlinx-cli = { module = "org.jetbrains.kotlinx:kotlinx-cli-jvm", version.ref =
142145
#### Test dependencies ####
143146
eclipse-jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "eclipse-jgit" }
144147

145-
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "gradlePlugin-kotlin" }
146-
147148
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
148149
junit-jupiterApi = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
149150
junit-jupiterParams = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy