close
Skip to content

ktfmt 0.51 incompatible with Spotless Gradle plugin #483

Description

@sgrimm

With the latest stable version (6.25.0) of the Spotless Gradle plugin, ktfmt 0.50 works but 0.51 fails with an error on ./gradlew spotlessApply:

com.facebook.ktfmt.format.FormattingOptions: method 'void <init>()' not found
java.lang.NoSuchMethodError: com.facebook.ktfmt.format.FormattingOptions: method 'void <init>()' not found
        at com.diffplug.spotless.glue.ktfmt.KtfmtFormatterFunc.createFormattingOptions(KtfmtFormatterFunc.java:61)
        at com.diffplug.spotless.glue.ktfmt.KtfmtFormatterFunc.apply(KtfmtFormatterFunc.java:54)
        at com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:32)
        at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:82)
        at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:103)
        at com.diffplug.spotless.Formatter.compute(Formatter.java:246)
        at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:203)
        at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:190)
        at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:105)
        at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:89)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)

I believe this is because commit 520706e added two arguments to FormattingOptions without default values, and Spotless is trying to call a no-arg constructor.

Not sure if this is something that needs to be fixed in ktfmt proper or in the Spotless ktfmt plugin; I've also filed diffplug/spotless#2171 on the Spotless side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions