kotlin-dsl-conventions
kotlin-dsl-conventions copied to clipboard
plugin seems to be incompatible with latest ktLint version
we configure the plugin like this:
ktlint {
disabledRules.set(
setOf(
"import-ordering",
"gradle-kotlin-dsl:gradle-kotlin-dsl-blank-lines",
"gradle-kotlin-dsl:gradle-kotlin-dsl-imports",
"gradle-kotlin-dsl:visibility-modifiers-own-line"
)
)
version.set(libs.versions.ktlint)
verbose.set(true)
}
currently we use ktlint version: "0.43.2", when trying to update this to e.g. "0.45.0" we get the following error:
$ gw ktLintFormat --stacktrace
-----------
* What went wrong:
Execution failed for task ':backend:runKtlintFormatOverTestSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> 'void com.pinterest.ktlint.core.Rule.<init>(java.lang.String)'
...
Caused by: java.lang.NoSuchMethodError: 'void com.pinterest.ktlint.core.Rule.<init>(java.lang.String)'
at com.pinterest.ktlint.ruleset.standard.CommentSpacingRule.<init>(CommentSpacingRule.kt:11)
at org.gradle.kotlin.dsl.ktlint.ruleset.GradleKotlinDslRuleSetProvider.get(GradleKotlinDslRuleSetProvider.kt:48)
at org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction.loadRuleSetsFromClasspath(KtLintWorkAction.kt:106)
at org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction.loadRuleSetsAndFilterThem(KtLintWorkAction.kt:95)
at org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction.execute(KtLintWorkAction.kt:20)
I encountered the same problem. Upgrading the Kotlin and ktlint versions for our custom rules worked for me, but that required some effort due to deprecations, breaking changes on 0.45, and new rules
- https://github.com/gradle/kotlin-dsl-conventions/pull/6 made this plugin work with ktlint-gradle 12.1.0 and ktlint 0.47.1
- Version 0.9.0 of the plugin was published
- More work is required to work with ktlint 1.x given the share of breaking changes