kotest-intellij-plugin icon indicating copy to clipboard operation
kotest-intellij-plugin copied to clipboard

K2 plugin migration

Open akozlova opened this issue 1 year ago • 8 comments

Evident usages of K1 api (resolve) are migrated

akozlova avatar Oct 01 '24 19:10 akozlova

@akozlova, could you please have a look at the test failures? There seems to be some Java version 17 vs 11 mismatch.

sschuberth avatar Oct 17 '24 06:10 sschuberth

Thanks for your work @akozlova!

i just wanted to report that I built the plugin locally (I commented everything but IC-242, because that's what I'm using, and also added kotlin.stdlib.default.dependency = false to gradle.properties because there was a warning about it. Not sure if that was necessary though). It seems to work fine with IU-242.23339.11 in K2 Mode! Incidentally, I got the same error about IC-243 as in the last pipeline run before I commented it, so this issue is probably real.

pschyska avatar Oct 17 '24 14:10 pschyska

I am sorry, which warning? Unfortunately I see compilation errors due to 2.1.0 used to compile new 243 builds and I can't fix it locally for now :/

akozlova avatar Oct 17 '24 14:10 akozlova

The warning was:

[org.jetbrains.intellij.platform] The following plugin configuration issues were found:
- The dependency on the Kotlin Standard Library (stdlib) is automatically added when using the Gradle Kotlin plugin and may conflict with the version provided with the IntelliJ Platform, see: https://jb.gg/intellij-platform-kotlin-stdlib

The given link mentions to add kotlin.stdlib.default.dependency = false to gradle.properties, which makes the warning go away. It is unrelated to the 243 issue I believe.

pschyska avatar Oct 17 '24 15:10 pschyska

With the following changes I could build 242 and 243 locally:

From 9cb825461f8848c0820c8341c07b1e179ecaa347 Mon Sep 17 00:00:00 2001
From: Paul Schyska <[email protected]>
Date: Thu, 17 Oct 2024 17:52:25 +0200
Subject: [PATCH] Bump kotlin to 2.0.21, don't ignore kotlinx-coroutines
 dependencies

---
 build.gradle.kts          | 10 +++++-----
 gradle.properties         |  2 ++
 gradle/libs.versions.toml |  2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index 19e28da..933ce47 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -172,11 +172,11 @@ dependencies {
 }

 configurations.all {
-   exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core-jvm")
-   exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
-   exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-jdk8")
-   exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-test")
-   exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-test-jvm")
+   // exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core-jvm")
+   // exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
+   // exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-jdk8")
+   // exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-test")
+   // exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-test-jvm")
 }

 sourceSets {
diff --git a/gradle.properties b/gradle.properties
index b571e4f..f9f6c6b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,3 +6,5 @@ version=1.1.0

 org.gradle.caching=true
 sandbox = /tmp/
+
+kotlin.stdlib.default.dependency = false
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 550808d..d395689 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,5 +1,5 @@
 [versions]
-kotlin = "1.9.25"
+kotlin = "2.0.21"
 runtime-kotest = "4.2.0"
 # We separate these from the actual runtime dependencies
 test-kotest = "5.9.1"
--
2.46.1

This updates kotlin to 2.0.21, and un-excludes kotlinx-coroutines dependencies. I don't know why they were excluded in the first place though, so this might wrong. I then ran:

PRODUCT_NAME=IC-243 JVM_TARGET=21 ./gradlew buildPlugin
PRODUCT_NAME=IC-242 JVM_TARGET=21 ./gradlew buildPlugin

and it built.

I don't have any intellij plugin experience, but maybe this helps you 😄

pschyska avatar Oct 17 '24 15:10 pschyska

Exclusion was done to avoid conflicts on runtime during running tests. 243 bundles patched version of coroutines and then it leads to exceptions like

ERROR: 'java.lang.Object kotlinx.coroutines.BuildersKt.runBlockingWithParallelismCompensation(kotlin.coroutines.CoroutineContext, kotlin.jvm.functions.Function2)'
java.lang.NoSuchMethodError: 'java.lang.Object kotlinx.coroutines.BuildersKt.runBlockingWithParallelismCompensation(kotlin.coroutines.CoroutineContext, kotlin.jvm.functions.Function2)'
	at kotlinx.coroutines.internal.intellij.IntellijCoroutines.runBlockingWithParallelismCompensation(intellij.kt:41)
	at com.intellij.openapi.progress.CoroutinesKt.runBlockingCancellable$lambda$0(coroutines.kt:146)
	at com.intellij.openapi.progress.ContextKt.prepareThreadContext(context.kt:85)
	at com.intellij.openapi.progress.CoroutinesKt.runBlockingCancellable(coroutines.kt:139)
	at com.intellij.openapi.progress.CoroutinesKt.runBlockingMaybeCancellable(coroutines.kt:175)
	at com.intellij.openapi.project.DumbServiceImpl.ensureInitialDumbTaskRequiredForSmartModeSubmitted(DumbServiceImpl.kt:702)
	at com.intellij.testFramework.IndexingTestUtil.shouldWait(IndexingTestUtil.kt:94)

But the idea is actually good, many thanks! I think, just excluding on runtime should do the trick.

akozlova avatar Oct 17 '24 19:10 akozlova

@sksamuel or @Kantis could you please have a look as well? I'm not familiar with the IntelliJ plugin API.

sschuberth avatar Oct 25 '24 08:10 sschuberth

This updates kotlin to 2.0.21, and un-excludes kotlinx-coroutines dependencies. I don't know why they were excluded in the first place though, so this might wrong. I then ran:

PRODUCT_NAME=IC-243 JVM_TARGET=21 ./gradlew buildPlugin
PRODUCT_NAME=IC-242 JVM_TARGET=21 ./gradlew buildPlugin

and it built.

I don't have any intellij plugin experience, but maybe this helps you 😄

They were excluded because otherwise there's a clash (or was, maybe excluding kotlin itself avoids that).

sksamuel avatar Oct 25 '24 22:10 sksamuel

We are going to release IJ 2024.3 in less than a month. K2 Mode won't be enabled by default but it would be really helpful to have the plugin ready. If there is something I can do, please let me know.

akozlova avatar Nov 07 '24 07:11 akozlova

@sksamuel as you've already approved, is there anything blocking the merge?

sschuberth avatar Nov 07 '24 08:11 sschuberth

Merged. Will test and release .

sksamuel avatar Nov 07 '24 16:11 sksamuel