Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable API for Spotless? #579

Closed
swankjesse opened this issue Sep 11, 2019 · 5 comments
Closed

Stable API for Spotless? #579

swankjesse opened this issue Sep 11, 2019 · 5 comments
Labels

Comments

@swankjesse
Copy link
Contributor

We upgraded from ktlint 0.33.0 to 0.34.2 and it caused our Spotless plugin to crash:

All input files are considered out-of-date for incremental task ':client:spotlessKotlin'.
Step 'ktlint' found problem in 'client/src/main/kotlin/com/squareup/cash/xxx/client/Xxxxx.kt':
com.pinterest.ktlint.core.KtLint.format(java.lang.String, java.lang.Iterable, java.util.Map, kotlin.jvm.functions.Function2)
java.lang.NoSuchMethodException: com.pinterest.ktlint.core.KtLint.format(java.lang.String, java.lang.Iterable, java.util.Map, kotlin.jvm.functions.Function2)
	at java.base/java.lang.Class.getMethod(Class.java:2108)
	at com.diffplug.spotless.kotlin.KtLintStep$State.createFormat(KtLintStep.java:140)
	at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:76)
	at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
	at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
	at com.diffplug.spotless.Formatter.applyToAndReturnResultIfDirty(Formatter.java:192)

Would it be worthwhile to lock down the API that Spotless uses to talk to Ktlint, so that Ktlint changes can’t break Spotless? Until that’s done it’s annoying to keep either project up-to-date.

@swankjesse
Copy link
Contributor Author

Oooh this is related: diffplug/spotless#419

@shashachu
Copy link
Contributor

@swankjesse yes, it's been reported on the Spotless side. As you probably know, we somewhat recently inherited the ktlint codebase, and breaking compatibility with Spotless was totally unintentional, as we didn't even realize the dependency existed. Moving forward, we'll be much more careful at talking to dependent projects if we ever decide to make a breaking API change.

For this particular issue, I'd prefer it be fixed on the Spotless API, as the API broke because we moved a lot of code into the ktlint-core module, out of Main.kt, so I'd rather not add backwards compatibility unless it turns out to be really onerous to fix for Spotless.

@kvnxiao
Copy link

kvnxiao commented Sep 17, 2019

Would you be working on a PR in the spotless repo to fix this? @shashachu

@ZacSweers
Copy link

I've PR'd a fix in diffplug/spotless#469

@Tapchicoma
Copy link
Collaborator

Ktlint has not yet reached stable 1.0.0 release meaning that most probably we may change api in the future. Though we will try to do it gracefully through deprecation and not break it in each release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants