Skip to content

Commit d1f64d8

Browse files
committed
Use compat-patrouille for compatibility settings
1 parent f4aaf9a commit d1f64d8

File tree

8 files changed

+25
-41
lines changed

8 files changed

+25
-41
lines changed

dokka-plugin/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ version = libs.versions.kotlinx.rpc.get()
1212

1313
logger.lifecycle("[Dokka Plugin] kotlinx.rpc project version: $version, Kotlin version: ${libs.versions.kotlin.lang.get()}")
1414

15-
kotlin {
16-
jvmToolchain(8)
17-
}
18-
1915
dependencies {
2016
compileOnly(libs.dokka.core)
2117
compileOnly(libs.dokka.base)

gradle-conventions/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies {
1212
implementation(libs.dokka.gradle.plugin)
1313
implementation(libs.gradle.doctor.gradle.plugin)
1414
implementation(libs.gradle.publish.gradle.plugin)
15+
implementation(libs.compat.patrouille.gradle.plugin)
1516

1617
implementation(libs.kover.gradle.plugin)
1718

gradle-conventions/src/main/kotlin/conventions-jvm.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
@file:OptIn(ExperimentalAbiValidation::class)
66

7+
import compat.patrouille.configureJavaCompatibility
8+
import compat.patrouille.configureKotlinCompatibility
79
import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation
810
import util.configureAbiFilters
911
import util.enableAbiValidation
@@ -18,11 +20,10 @@ java {
1820
withSourcesJar()
1921
}
2022

21-
kotlin {
22-
jvmToolchain {
23-
languageVersion.set(JavaLanguageVersion.of(8))
24-
}
23+
configureJavaCompatibility(8)
24+
configureKotlinCompatibility("2.0.0")
2525

26+
kotlin {
2627
explicitApi()
2728

2829
abiValidation {

gradle-conventions/src/main/kotlin/conventions-kmp.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
@file:OptIn(ExperimentalAbiValidation::class)
66

7+
import compat.patrouille.configureJavaCompatibility
8+
import compat.patrouille.configureKotlinCompatibility
79
import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation
810
import util.*
911
import util.targets.configureJs
@@ -38,3 +40,6 @@ withKmpConfig {
3840
}
3941

4042
configureJvm(isKmp = true)
43+
44+
configureJavaCompatibility(8)
45+
configureKotlinCompatibility("2.0.0")

gradle-conventions/src/main/kotlin/conventions-kotlin-version.gradle.kts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
65
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
7-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
8-
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
96
import util.withKotlinJvmExtension
107
import util.withKotlinKmpExtension
118

@@ -16,27 +13,10 @@ fun KotlinProjectExtension.optInForRpcApi() {
1613
}
1714
}
1815

19-
/**
20-
* Set the compatibility mode to the lower supported language version.
21-
*
22-
* This should be lined up with the minimal supported compiler plugin version.
23-
*
24-
* We update the language version only for the 'main' sources sets.
25-
* This makes our tests execute against the latest compiler plugin version (for example, with K2 instead of K1).
26-
*/
27-
fun KotlinCommonCompilerOptions.setProjectLanguageVersion() {
28-
languageVersion.set(KotlinVersion.KOTLIN_2_0)
29-
apiVersion.set(KotlinVersion.KOTLIN_2_0)
30-
}
31-
3216
withKotlinJvmExtension {
3317
optInForRpcApi()
34-
35-
compilerOptions.setProjectLanguageVersion()
3618
}
3719

3820
withKotlinKmpExtension {
3921
optInForRpcApi()
40-
41-
compilerOptions.setProjectLanguageVersion()
4222
}

gradle-conventions/src/main/kotlin/util/targets/configure.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ fun KmpConfig.configureKotlinExtension(action: Action<KotlinMultiplatformExtensi
6060

6161
configureDetekt(includedTargets)
6262

63-
jvmToolchain {
64-
languageVersion.set(JavaLanguageVersion.of(8))
65-
}
66-
6763
action.execute(this)
6864
}
6965
}

krpc/krpc-test/build.gradle.kts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ plugins {
1616
alias(libs.plugins.atomicfu)
1717
}
1818

19-
tasks.withType<KotlinCompile> {
20-
if (this.name.contains("Test")) {
21-
compilerOptions {
22-
// for kotlin.time.Clock API
23-
languageVersion.set(KotlinVersion.KOTLIN_2_1)
24-
apiVersion.set(KotlinVersion.KOTLIN_2_1)
19+
kotlin {
20+
targets.all {
21+
compilations.matching {
22+
it.name.lowercase().endsWith("test")
23+
}.all {
24+
compileTaskProvider.configure {
25+
compilerOptions {
26+
languageVersion.set(KotlinVersion.KOTLIN_2_1)
27+
apiVersion.set(KotlinVersion.KOTLIN_2_1)
28+
}
29+
}
2530
}
2631
}
27-
}
2832

29-
kotlin {
3033
sourceSets {
3134
commonMain {
3235
dependencies {

versions-root/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ detekt-gradle-plugin = "1.23.8"
2828
kover = "0.9.1"
2929
develocity = "3.19.2"
3030
common-custom-user-data = "2.3"
31+
compat-patrouille = "0.0.0"
3132

3233
[libraries]
3334
# kotlinx.rpc – references to the included builds
@@ -110,6 +111,7 @@ kover-gradle-plugin = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", ve
110111
dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
111112
gradle-doctor-gradle-plugin = { module = "com.osacky.doctor:doctor-plugin", version.ref = "gradle-doctor" }
112113
gradle-publish-gradle-plugin = { module = "com.gradle.publish:plugin-publish-plugin", version.ref = "gradle-plugin-publish" }
114+
compat-patrouille-gradle-plugin = { module = "com.gradleup.compat.patrouille:compat-patrouille-gradle-plugin", version.ref = "compat-patrouille" }
113115

114116
[plugins]
115117
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin-lang" }

0 commit comments

Comments
 (0)