Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 2.1 Compatibility Issue #2882

Closed
hantsy opened this issue Nov 29, 2024 · 6 comments
Closed

Kotlin 2.1 Compatibility Issue #2882

hantsy opened this issue Nov 29, 2024 · 6 comments
Milestone

Comments

@hantsy
Copy link

hantsy commented Nov 29, 2024

After several hours of research yesterday, I found the Kotlinter gradle broke our project build when upgrading Kotlin 2.1.

I tried to fork and update Kotin Kotlinter to Kotlin 2.1 but it did not resolve the issue.

The root cause is from Klint, check the issue discussion here: jeremymailen/kotlinter-gradle#414 (comment)

> Task :lintKotlinIntegration FAILED
lint worker execution error
java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/internal/config/CompilerConfigurationKey
	at org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar$Companion.<clinit>(ComponentRegistrar.kt:33)
	at org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.<clinit>(ComponentRegistrar.kt)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli_base(KotlinCoreEnvironment.kt:753)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:194)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.configureProjectEnvironment(KotlinCoreEnvironment.kt:652)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:224)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:468)
	at com.pinterest.ktlint.rule.engine.internal.KotlinPsiFileFactoryKt.initPsiFileFactory(KotlinPsiFileFactory.kt:58)
	at com.pinterest.ktlint.rule.engine.internal.KotlinPsiFileFactoryProvider.getKotlinPsiFileFactory(KotlinPsiFileFactory.kt:32)
	at com.pinterest.ktlint.rule.engine.internal.RuleExecutionContext$Companion.createRuleExecutionContext$ktlint_rule_engine(RuleExecutionContext.kt:212)
	at com.pinterest.ktlint.rule.engine.internal.CodeFormatter.format(CodeFormatter.kt:51)
	at com.pinterest.ktlint.rule.engine.internal.CodeFormatter.format(CodeFormatter.kt:28)
	at com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine.lint(KtLintRuleEngine.kt:91)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerAction.execute(LintWorkerAction.kt:49)
@paul-dingemans
Copy link
Collaborator

Ktlint uses the Kotlin 2.0.21 embedded compiler. #2880 also shows that upgrade to 2.1 is failing as some keywords have been removed which did exist in 2.0.21.

@paul-dingemans paul-dingemans added this to the 1.5 milestone Nov 29, 2024
@hantsy
Copy link
Author

hantsy commented Nov 30, 2024

Besides calling the legacy method, you should also consider handling the dependency kotlin-compiler-embeddable. When upgrading to Kotlin 2.1.0, a warning is raised when building the project.

Check: https://kotlinlang.org/docs/whatsnew21.html#compiler-symbols-hidden-from-the-kotlin-gradle-plugin-api

@paul-dingemans
Copy link
Collaborator

Besides calling the legacy method, you should also consider handling the dependency kotlin-compiler-embeddable. When upgrading to Kotlin 2.1.0, a warning is raised when building the project.

Check: https://kotlinlang.org/docs/whatsnew21.html#compiler-symbols-hidden-from-the-kotlin-gradle-plugin-api

Which legacy method do you mean?

@hantsy
Copy link
Author

hantsy commented Dec 2, 2024

Which legacy method do you mean?

The exceptions caused the build failure.

@paul-dingemans
Copy link
Collaborator

Please keep in mind that I don't run kotlinter (nor any other Ktlint integrator). So I cannot verify myself whether the problem is solved if I do not know exactly what to resolve. So either you have to provide me with a reproduction path with Ktlint CLI, or with enough detailed information so that I can check with enough certainity that it is resolved.

@paul-dingemans
Copy link
Collaborator

For now, I am assuming that this has been validated in the kolinter issue which was fixed by PR #2880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants