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

Changes in .editorconfig file are ignored on subsequent reruns #456

Closed
G00fY2 opened this issue Mar 17, 2021 · 7 comments · Fixed by #469
Closed

Changes in .editorconfig file are ignored on subsequent reruns #456

G00fY2 opened this issue Mar 17, 2021 · 7 comments · Fixed by #469
Labels

Comments

@G00fY2
Copy link

G00fY2 commented Mar 17, 2021

After updating to ktlint 0.41.0 I get:

A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
   java.lang.RuntimeException: Unexpected imports layout: "*,java.**,javax.**,kotlin.**,^"

I know about the changes made regarding pinterest/ktlint#1018 and tried different configurations in my .editorconfig. But non of these seems to work:

kotlin_imports_layout=idea
ij_kotlin_imports_layout=*
ij_kotlin_imports_layout=*,java.,javax.,kotlin.**,^

Not sure if this is an incompatibility with the plugin oder a general ktlint issue.

Plugin Version: 10.0.0
Ktlint Version: 0.41.0
Gradle Version: 6.8.3
Android Studio: 4.1.2

@Tapchicoma
Copy link
Collaborator

What is your ktlint { .. } configuration in Gradle and whole .editorconfig content?

Would be nice to create some project that reproduces the issue.

@G00fY2
Copy link
Author

G00fY2 commented Mar 17, 2021

Thats the project where I get this issue: https://github.com/G00fY2/quickie

@romtsn
Copy link

romtsn commented Mar 18, 2021

@G00fY2 I've just tried your project, and it works fine for me. You probably ran into some internal caching of ktlint, hence were facing the old error, even though the imports_layout has been changed to the correct one.

Just to reinforce, this is how it should be defined in the .editorconfig to comply with IDEA and ktlint:

ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^

and then ./gradlew ktlintCheck --rerun-tasks to make sure you're not hitting the invalid cache.

@G00fY2
Copy link
Author

G00fY2 commented Mar 18, 2021

Hmm, yeah you are right. Has to be some caching issue. I just updated everything and the CI builds run fine.

I also used the correct import regex (copy and pasted it from ktlint readme), not sure why the one in my description is different.

Thanks! And sorry for bringing this up.

@G00fY2 G00fY2 closed this as completed Mar 18, 2021
@Tapchicoma
Copy link
Collaborator

Tapchicoma commented Mar 20, 2021

Actually it is a bug in the plugin and how it handles KtLint .editorconfig cache. Should be fixed for the next release.

@Tapchicoma
Copy link
Collaborator

Just FYI: as workaround you have to stop Gradle daemon (so it will kill workers) after any .editorconfig changes.

@Tapchicoma Tapchicoma changed the title Unexpected imports with ktlint 0.41.0 Changes in .editorconfig file are ignored on subsequent reruns Apr 7, 2021
@amatkivskiy
Copy link

amatkivskiy commented May 14, 2021

Thanks @Tapchicoma

⚠️ For anyone facing an issue that ktlint ignores any changes in .editorconfig -> run ./gradlew --stop and then rerun ktlint task.

⚠️⚠️⚠️ This should be mentioned somewhere in README.MD

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

Successfully merging a pull request may close this issue.

4 participants