ktlint-gradle icon indicating copy to clipboard operation
ktlint-gradle copied to clipboard

The plugin does not work when using Ktlint 0.46.0

Open mars885 opened this issue 3 years ago • 9 comments

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

mars885 avatar Jun 19 '22 11:06 mars885

A PR that addresses the issue would be appreciated 🙂

JLLeitschuh avatar Jun 22 '22 14:06 JLLeitschuh

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 avatar Jun 29 '22 16:06 scana

@scana could you do so in such a way that preserves backwards compatibility by using reflection to call the old APIs?

JLLeitschuh avatar Jun 29 '22 16:06 JLLeitschuh

@JLLeitschuh unfortunately not, because they have also changed ReporterProvider signature to ReporterProvider<T : Reporter>

scana avatar Jun 29 '22 16:06 scana

with:

tlint-gradle: 10.3.0 ktlint: 0.46.1

still getting the following exception:

Screenshot 2022-08-17 at 13 07 28

jzeferino avatar Aug 17 '22 12:08 jzeferino

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 :-)

mikehardy avatar Aug 19 '22 01:08 mikehardy

As stated in this PR I think even though there was a 11.0.0 major release, this issue is still unchanged.

G00fY2 avatar Aug 25 '22 07:08 G00fY2

Same issue with all ktlint versions >0.45.2, including 0.47.0

DmitriyZaitsev avatar Aug 31 '22 16:08 DmitriyZaitsev

@DmitriyZaitsev edited his comment to be more collaborative / informative, so I am editing mine to be much more friendly :-)

mikehardy avatar Sep 01 '22 23:09 mikehardy

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?

scottkennedy avatar Nov 17 '22 18:11 scottkennedy

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

konstantin-rudoi-nix avatar Nov 30 '22 16:11 konstantin-rudoi-nix

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

konstantin-rudoi-nix avatar Jan 16 '23 17:01 konstantin-rudoi-nix

My pr #620 will resolve this issue. I am putting the finishing touches on it and will hopefully merge it later this week

wakingrufus avatar Jan 16 '23 17:01 wakingrufus

https://github.com/JLLeitschuh/ktlint-gradle/releases/tag/v11.1.0

JLLeitschuh avatar Jan 27 '23 17:01 JLLeitschuh