ktlint-gradle
ktlint-gradle copied to clipboard
Error with kotlin 2.0.1
Hi, I'm getting an error when executing the ktlintCheck task. The error is:
Execution failed for task ':runKtlintCheckOverKotlinScripts'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> Class org.jetbrains.kotlin.lexer.KtTokens does not have member field 'org.jetbrains.kotlin.lexer.KtModifierKeywordToken HEADER_KEYWORD'
I found that this keyword was removed in the most recent versions of the Kotlin compiler. Is the current version of ktlint aware of this?
Thanks!
This might be about Kotlin 2.1.0, not 2.0.1.
This error has been fixed in ktlint lib version 1.4.0, but this plugin is using an slightly older version of the lib.
In build.gradle.kts we can configure the plugin to use the most recent version of ktlint.
ktlint {
version.set("1.4.1")
}
That should fix the error for now.
A PR updating the default Ktlint version would be appreciated and accepted with a simple unit test and a CHANGELOG entry
I hope this PR is what you were looking for: #818
setting to ktlint version to 1.5 leads to failing on a lot of validations, did anyone experienced the same?
setting to ktlint version to 1.5 leads to failing on a lot of validations, did anyone experienced the same?
if you were p reviously on a pre-1.0 version of ktlint, then yeah a lot of things changed in ktlint. This is a big reason why we have been dragging our feet on updating the default version in ktlint-gradle. I recommend looking at the ktlint github for advise on the changes to the ktlint rules
thank a lot, already found some info and it seems that this setup solved quite a lot, as I understood that prior version where same as in IntelliJ. Additionally will add separately what's failing. Thanks a lot for quick answer!
additionalEditorconfig = [ 'ktlint_code_style': 'intellij_idea' ]
I believe this issue can be closed with https://github.com/JLLeitschuh/ktlint-gradle/releases/tag/v13.0.0 that sets the default ktlint version to 1.5
This is still valid issue for me with v13.0.0 and Kotlin v2.2.0
We did indeed upgrade the default ktlint version in 13.0. We will continue to update this each time we do a major version bump