Skip to content

Commit 25f1441

Browse files
committed
Update the project to run tests without the useK2Plugin property (#156)
1 parent c177544 commit 25f1441

File tree

11 files changed

+59
-61
lines changed

11 files changed

+59
-61
lines changed

compiler-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ allprojects {
1212
version = "$kotlinVersion-$rpcVersion"
1313
}
1414

15-
configureMetaTasks("cleanTest", "test")
15+
configureMetaTasks("clean", "cleanTest", "test")
1616
configureMetaTasks(tasks.matching { it.name.startsWith("publish") }.map { it.name })

gradle-conventions-settings/src/main/kotlin/util/metaTask.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ fun Project.configureMetaTasks(taskNames: List<String>, excludeSubprojects: List
1414
val root = this
1515
val metaSet = taskNames.toSet()
1616

17+
metaSet.forEach { taskName ->
18+
root.tasks.maybeCreate(taskName).apply {
19+
group = "meta"
20+
}
21+
}
22+
1723
subprojects.forEach {
1824
if (it.name in excludeSubprojects) {
1925
return@forEach
@@ -23,12 +29,9 @@ fun Project.configureMetaTasks(taskNames: List<String>, excludeSubprojects: List
2329
val subtask = this
2430

2531
if (subtask.name in metaSet) {
26-
val metaTask = root.tasks.findByName(subtask.name)
27-
?: root.task(subtask.name)
32+
val metaTask = root.tasks.named(subtask.name).get()
2833

2934
metaTask.dependsOn(subtask)
30-
31-
metaTask.group = "meta"
3235
}
3336
}
3437
}

gradle-conventions/latest-only/src/main/kotlin/conventions-kotlin-version-jvm.gradle.kts

Lines changed: 0 additions & 13 deletions
This file was deleted.

gradle-conventions/latest-only/src/main/kotlin/conventions-kotlin-version-kmp.gradle.kts

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
6+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
7+
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
8+
import util.lowercase
9+
import util.withKotlinJvmExtension
10+
import util.withKotlinKmpExtension
11+
12+
/**
13+
* Set the compatibility mode to the lower supported language version.
14+
*
15+
* This should be lined up with the minimal supported compiler plugin version.
16+
*
17+
* We update the language version only for the 'main' sources sets.
18+
* This makes our tests execute against the latest compiler plugin version (for example, with K2 instead of K1).
19+
*/
20+
fun KotlinCommonCompilerOptions.setProjectLanguageVersion() {
21+
languageVersion.set(KotlinVersion.KOTLIN_1_7)
22+
apiVersion.set(KotlinVersion.KOTLIN_1_7)
23+
}
24+
25+
withKotlinJvmExtension {
26+
target.compilations
27+
.filter { it.isMain }
28+
.forEach { compilation ->
29+
compilation.compileJavaTaskProvider.configure {
30+
compilerOptions.setProjectLanguageVersion()
31+
}
32+
}
33+
}
34+
35+
withKotlinKmpExtension {
36+
targets.flatMap { it.compilations }
37+
.filter { it.isMain }
38+
.forEach { compilation ->
39+
compilation.compileTaskProvider.configure {
40+
compilerOptions.setProjectLanguageVersion()
41+
}
42+
}
43+
}
44+
45+
val KotlinCompilation<*>.isMain get() = name.lowercase().contains("main")

gradle-conventions/latest-only/src/main/kotlin/util/CompilerOptions.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import util.whenKotlinLatest
99
plugins {
1010
id("io.gitlab.arturbosch.detekt")
1111
id("conventions-publishing")
12+
id("conventions-kotlin-version")
1213
}
1314

1415
val globalRootDir: String by extra

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import util.optInForRPCApi
88
plugins {
99
id("conventions-common")
1010
id("org.jetbrains.kotlin.jvm")
11-
id("conventions-kotlin-version-jvm")
1211
}
1312

1413
java {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import util.optionalProperty
1010
plugins {
1111
id("conventions-common")
1212
id("org.jetbrains.kotlin.multiplatform")
13-
id("conventions-kotlin-version-kmp")
1413
}
1514

1615
configure<KotlinMultiplatformExtension> {

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,3 @@ systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true
3131

3232
# uncomment to debug compilation process
3333
#kotlin.compiler.execution.strategy=in-process
34-
35-
# set to true to use K2 RPC compiler plugin to build and run the project (including tests)
36-
kotlinx.rpc.useK2Plugin=false

0 commit comments

Comments
 (0)