Repository navigation
Update to Kotlin 2.0.0 - #6640
Conversation
|
Hey @3flex after trying the commit 429a178 as you mentioned here #6715 (comment). I've been able to compile your branch and generate the library on my MavenLocal. But when I've run Thanks :) |
|
You probably need to follow steps here: https://docs.gradle.org/8.3/release-notes.html#kotlin_k2 and be sure to use Gradle 8.3 or higher. Also have a read of https://kotlinlang.org/docs/whatsnew-eap.html#current-k2-compiler-limitations |
8652daa to
68f3cc7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6640 +/- ##
============================================
- Coverage 84.68% 84.36% -0.33%
- Complexity 4001 4176 +175
============================================
Files 574 574
Lines 12011 11913 -98
Branches 2476 2458 -18
============================================
- Hits 10172 10050 -122
- Misses 598 613 +15
- Partials 1241 1250 +9 ☔ View full report in Codecov by Sentry. |
|
If this is cherry picked into the 1.x branch, these PRs will also need to be picked: |
|
Kotlin 2.0 has just been released. I see this has been merged - are you planning to publish a release relatively soon? :) |
|
I haven't made releases previously so I can't say, but you can try snapshots until a new one is pushed out. |
|
@cortinico are you planning a patch with Kotlin 2.0.0 support? (current 1.23.6 works, but I would assume that the K2 improvements propagate to compiler-embedded, so a detekt patch/minor release could benefit from a 2x speed improvement?) |
I was thinking we can cut a |
|
It feels like that might be a long way away (from stable), there are still breaking changes coming in refractors, right? So alpha would require some to migrate again and again, and therefore I personally wouldn't actually use the alpha in a live project (e.g. at work) and miss out on speed of a stable compiler. I think @3flex can comment on the complexity of cherry, based on the above comment it's 3 small PRs, however with one of them forcing language version, does it mean we wouldn't benefit from K2's improvements? |
|
Language version 1.9 limitation applies to compiler plugin only. The CLI and Gradle in theory get speedups but I haven't tested anything. Cherry picking sounds like a good plan. |
|
Looking forward to using Do you see any chances of publishing alpha or even a safe snapshot version for testing? Or maybe you have a timeline for when that might happen? |
|
I have successfully updated my company’s project to Kotlin 2.0, including the compiler plugin. However, we are currently blocked by detekt not supporting Kotlin 2.0. |
|
detekt WORKS with Kotlin 2.0. If it doesn't work for you then it's probably an issue in your configuration. If you need help you can use the discussions. |
|
Interesting. I simply added This matches the problem raised in #7382, for which the solution was apparently this PR that I don't think was released yet? |
|
You can use snapshot versions until there's a new release that has Kotlin 2 built in to get around the JVM issue. The compiler plugin works with Kotlin 2 but only if the language version is 1.9 and lower. That gap is tracked in #7304. |
Does this mean it works with the snapshot version? Or does it also support version 1.23.6? |
|
The current stable version of detekt works with kotlin 2.0 |
To recap, because I think I'm just not expressing my issues correctly - In the meantime the best bet for folks in my situation is to build and use a snapshot version. Is that correct? |
|
@karolgil I think the compiler and detekt language versions don't have to match, because there are no new language features in 2.0, unless you're using the compiler plugin, which is not the default when you use Detekt Gradle Plugin as far as I know. Other than the Java 22 issue, are you facing actual problems using detekt 1.23.6 in a Kotlin 2 project? |
I use 1.23.6 with kotlin 2.0 without any problem. So, what I mean, is that the church stable version of detekt already supports kotlin 2.0. |
Now I can also use detekt 1.23.6 with Kotlin 2.0, but I need to use Kotlin v1 for detekt. This is my project.afterEvaluate {
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion("1.9.23")
}
}
}
} |
|
I don't use spring boot so I don't need that. But yes. That's expected. |
|
I got it to work. Initially I was following the getting started documentation but today I decided to take a look at the README. After adding the following the I guess I don't have to understand the details of it but I'm still confused as to why that's needed. |
That is not longer needed on detekt 2.0 (current SNAPSHOT). But for 1.0 you need to set up that. Also, if there is anything in the documentation that isn't clear, please, could you open a PR updating it so the next one doesn't find the same issue? |
|
Hi, is the snapshot version also recommended for ruleset maintainers? I see quite some compilation errors after upgrading from 1.23.6 to main-SNAPSHOT. Just wonder if we should fix these errors now or wait until the stable release is out. |
|
The apis are still not stable so they can still change. But, it would be great if you can update and provide us feedback about how the new apis feel. |
|
Thanks Brais. If we use the snapshot version, it would be best to stick to a specific date to prevent our pipeline from breaking due to unexpected API changes. I noticed that the earliest version in the snapshot repository is from 8/28. Does the repository have a short retention period? |
That depends on Sonatype's retention period (we don't control it) |
|
Thanks. Do you have a rough estimate when we can expect a stable version of it? |
We're going to release this in 1.23.7 as soon as we fix the last remaining issues we have with the CI |
Fixes #6715
Fixes #7458
This is safe to release with alpha/beta dependencies in my opinion. poko 0.16.0-beta01 is based on Kotlin 2.0.0-RC3 which is the same as 2.0.0. kctfork is only used in tests.