Skip to content

Commit

Permalink
Update the project to run tests without the useK2Plugin property (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr3zee authored Aug 8, 2024
1 parent 600b025 commit 9c46d86
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ allprojects {
version = "$kotlinVersion-$rpcVersion"
}

configureMetaTasks("cleanTest", "test")
configureMetaTasks("clean", "cleanTest", "test")
configureMetaTasks(tasks.matching { it.name.startsWith("publish") }.map { it.name })
11 changes: 7 additions & 4 deletions gradle-conventions-settings/src/main/kotlin/util/metaTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ fun Project.configureMetaTasks(taskNames: List<String>, excludeSubprojects: List
val root = this
val metaSet = taskNames.toSet()

metaSet.forEach { taskName ->
root.tasks.maybeCreate(taskName).apply {
group = "meta"
}
}

subprojects.forEach {
if (it.name in excludeSubprojects) {
return@forEach
Expand All @@ -23,12 +29,9 @@ fun Project.configureMetaTasks(taskNames: List<String>, excludeSubprojects: List
val subtask = this

if (subtask.name in metaSet) {
val metaTask = root.tasks.findByName(subtask.name)
?: root.task(subtask.name)
val metaTask = root.tasks.named(subtask.name).get()

metaTask.dependsOn(subtask)

metaTask.group = "meta"
}
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import util.lowercase
import util.withKotlinJvmExtension
import util.withKotlinKmpExtension

/**
* Set the compatibility mode to the lower supported language version.
*
* This should be lined up with the minimal supported compiler plugin version.
*
* We update the language version only for the 'main' sources sets.
* This makes our tests execute against the latest compiler plugin version (for example, with K2 instead of K1).
*/
fun KotlinCommonCompilerOptions.setProjectLanguageVersion() {
languageVersion.set(KotlinVersion.KOTLIN_1_7)
apiVersion.set(KotlinVersion.KOTLIN_1_7)
}

withKotlinJvmExtension {
target.compilations
.filter { it.isMain }
.forEach { compilation ->
compilation.compileJavaTaskProvider.configure {
compilerOptions.setProjectLanguageVersion()
}
}
}

withKotlinKmpExtension {
targets.flatMap { it.compilations }
.filter { it.isMain }
.forEach { compilation ->
compilation.compileTaskProvider.configure {
compilerOptions.setProjectLanguageVersion()
}
}
}

val KotlinCompilation<*>.isMain get() = name.lowercase().contains("main")

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import util.whenKotlinLatest
plugins {
id("io.gitlab.arturbosch.detekt")
id("conventions-publishing")
id("conventions-kotlin-version")
}

val globalRootDir: String by extra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import util.optInForRPCApi
plugins {
id("conventions-common")
id("org.jetbrains.kotlin.jvm")
id("conventions-kotlin-version-jvm")
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import util.optionalProperty
plugins {
id("conventions-common")
id("org.jetbrains.kotlin.multiplatform")
id("conventions-kotlin-version-kmp")
}

configure<KotlinMultiplatformExtension> {
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@ systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true

# uncomment to debug compilation process
#kotlin.compiler.execution.strategy=in-process

# set to true to use K2 RPC compiler plugin to build and run the project (including tests)
kotlinx.rpc.useK2Plugin=false
5 changes: 5 additions & 0 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3267,6 +3267,11 @@ type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"

[email protected]:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==

[email protected]:
version "5.4.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff"
Expand Down

0 comments on commit 9c46d86

Please sign in to comment.