ktlint-gradle
ktlint-gradle copied to clipboard
The plugin does not work when using Ktlint 0.46.0
The Ktlint 0.46.0 has been released recently with breaking API changes that make using the plugin impossible. One such change is that Ktlint.Params class has been renamed into the ExperimentalParams.
As a result of this, when I run the ./gradlew ktlintCheck --continue command, I get the following:
> Task :app:runKtlintCheckOverKotlinScripts FAILED
> Task :app:runKtlintCheckOverMainSourceSet FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:runKtlintCheckOverKotlinScripts'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> com/pinterest/ktlint/core/KtLint$Params
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:runKtlintCheckOverMainSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> com/pinterest/ktlint/core/KtLint$Params
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
10 actionable tasks: 3 executed, 7 up-to-date
The versions used are the following:
- ktlint-gradle:
10.3.0 - ktlint:
0.46.0
A PR that addresses the issue would be appreciated 🙂
Hey @JLLeitschuh, I have it almost ready, but it seems like it would require updating the whole project (and samples) to Kotlin 1.6.21 and then it will not be backward-compatible with earlier ktlint versions (due to 0.46 introducing breaking changes).
I'll open it soon so maybe @JLLeitschuh or @Tapchicoma could take a look (I've read https://github.com/JLLeitschuh/ktlint-gradle/issues/569 so I know how it looks like time-wise)
@scana could you do so in such a way that preserves backwards compatibility by using reflection to call the old APIs?
@JLLeitschuh unfortunately not, because they have also changed ReporterProvider signature to ReporterProvider<T : Reporter>
with:
tlint-gradle: 10.3.0 ktlint: 0.46.1
still getting the following exception:
Please take this in the light-hearted spirit it is intended but: change all the things, issue a major version (semantic-version-wise) and sleep well at night :-)
As stated in this PR I think even though there was a 11.0.0 major release, this issue is still unchanged.
Same issue with all ktlint versions >0.45.2, including 0.47.0
@DmitriyZaitsev edited his comment to be more collaborative / informative, so I am editing mine to be much more friendly :-)
Please take this in the light-hearted spirit it is intended but: change all the things, issue a major version (semantic-version-wise) and sleep well at night :-)
Given how long this issue has been open and unresolved, is this something we could do? Create a 12.0.0 and just say that as of that version of this plugin, only ktlint 0.46.0 and newer are supported?
The same problem
Execution failed for task ':app:runKtlintCheckOverKotlinScripts'.
Execution failed for task ':app:runKtlintCheckOverMainSourceSet'.
Execution failed for task ':app:runKtlintCheckOverTestSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> com/pinterest/ktlint/core/KtLint$Params
com.android.tools.build:gradle = "7.4.0" kotlin = "1.8.0" ktlint = "0.48.1"
> Task :app:runKtlintCheckOverMainSourceSet FAILED
> Task :app:runKtlintCheckOverTestSourceSet FAILED
> Task :app:runKtlintCheckOverKotlinScripts FAILED
FAILURE: Build completed with 3 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:runKtlintCheckOverKotlinScripts'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> Could not create an instance of type org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction.
> Could not generate a decorated class for type KtLintWorkAction.
> com/pinterest/ktlint/core/ParseException
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:runKtlintCheckOverMainSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> Could not create an instance of type org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction.
> Could not generate a decorated class for type KtLintWorkAction.
> com/pinterest/ktlint/core/ParseException
3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:runKtlintCheckOverTestSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
> Could not create an instance of type org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction.
> Could not generate a decorated class for type KtLintWorkAction.
> com/pinterest/ktlint/core/ParseException
My pr #620 will resolve this issue. I am putting the finishing touches on it and will hopefully merge it later this week
https://github.com/JLLeitschuh/ktlint-gradle/releases/tag/v11.1.0