kotlinter-gradle: Kotlin 2.1.0 failure
I tried to update Kotlin to 2.1.0 but encountered a build error.
'void org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments.setExtraWarnings(boolean)'
It could be an issue kotlinter called the old kotlin compiler 1.9 APIs, https://kotlinlang.slack.com/archives/C0KLZSCHF/p1729256644747559?thread_ts=1729151089.194689&cid=C0KLZSCHF
Thank @dawiddc for posting the debug info, please vote https://github.com/pinterest/ktlint/issues/2882
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 22
- Comments: 18 (6 by maintainers)
I need to solve a few other bugs related to Kotlin 2.1. Will do my best to release this week.
Status update. Fixing this will require classloader isolation. I have a PR out which I will test further on some substantial projects. And an additional PR will be needed to maintain support for custom rules. In the end there will be a 5.0.0 release and it will be a substantial change, but hopefully for the better.
Should now be fixed in 5.0.0. Please give it a try.
Our error after update from Kotlin 2.0.21 to 2.1.0 (kotlinter 4.5.0):
I can confirm that 5.0.0 version fixed the problem. Thanks!
Hi! I ran into this in https://github.com/JetBrains/Jewel — I asked folks in JetBrains for help, and they could repro, see KT-73761.
The root cause is kotlinter putting kotlin-compiler-embeddable on the buildscript classpath, which causes it to fail when using Kotlin 2.1.0 as the 1.9.24 version kotlinter uses is binary incompatible.
In the meantime, the fix for us was to explicitly put the right version of the compiler in the buildSrc classpath: https://github.com/JetBrains/jewel/commit/8191612ec5e2295ab37a453378641b7e4cf74780
Just thought this could be helpful, even tho the issue seems to be worked on already.
@rock3r I have tried to add it explicitly to build script classpath like.
But it did not work.
More information about this issue available here: https://youtrack.jetbrains.com/issue/KT-70543/Gradle-create-migration-guide-for-those-who-are-using-Kotlin-compiler-classes-indirectly-available-in-buildscripts
There’s indeed some required fixes in kotlinter to make it work with 2.1.0.