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

Spotless Gradle plugin doesn't respect .editorconfig changes when using daemon #1924

Open
4 tasks done
0legg opened this issue Dec 1, 2023 · 9 comments
Open
4 tasks done
Labels

Comments

@0legg
Copy link

0legg commented Dec 1, 2023

  • summary of problem
    Steps to reproduce:

  • enable Gradle daemon

  • run ./gradlew spotlessCheck with some failing rule.

  • disable said rule in .editorconfig

  • run ./gradlew spotlessCheck again.

Expected: check passes.
Actual: check fails again.

Adding a --no-daemon command line parameter to second invocation resolves the issue; which hints that daemon somehow caches file contents, or doesn't treat it as an input to Gradle task.

  • Gradle or Maven version
    Gradle 8.4, 8.5

  • spotless version
    Spotless 6.23.1

  • operating system and version
    macos Sonoma, 14.1.1

@Goooler
Copy link
Member

Goooler commented Dec 2, 2023

Seems I've experienced this issue.

@0legg
Copy link
Author

0legg commented Dec 2, 2023

By some coincidence issues like #1913 were reproducible for me from time to time with daemon on, and disappeared when I explicitly turned off the daemon. It makes me think that Spotless somehow corrupts saved state.

@galiren
Copy link

galiren commented Jan 1, 2024

Also reproduced when I changed .editorconfig indent_size from 4 to 2 and run gradlew spotlessApply, the file indent keeps exact 4 spaces. I use editorconfig with ktlint btw.

@0legg
Copy link
Author

0legg commented Jan 12, 2024

@Goooler Could your change in #1890 somehow affect how .editorconfig is accessed (or maybe it was always working this way)? I don't see what is triggering KtlintConfig recreation, and I bet if the daemon keeps to the old instance, the file content is frozen in memory as well.

@Goooler
Copy link
Member

Goooler commented Jan 13, 2024

That change isn't related to this issue, I observed this issue a long time ago.

@stkent
Copy link

stkent commented Mar 28, 2024

I ran into something that sounds like this today. I found that adding a clean (i.e. running ./gradlew clean spotlessCheck rather than ./gradlew spotlessCheck) after changes to the .editorconfig file resolved the issue for me. Perhaps task output caching logic is incorrect?

@TWiStErRob
Copy link

TWiStErRob commented May 4, 2024

Just wasted another half hour on this, trying to configure ktlint, but not observing the changes.

When authoring configuration we must use gradlew spotlessApply --no-daemon. This is really inefficient in projects without configuration cache.

@madorb
Copy link

madorb commented Jun 6, 2024

Took me quite a while yesterday to figure out that this was the reason .editorconfig changes appeared to not be taking affect.

niyajali added a commit to niyajali/liveshopping-android that referenced this issue Aug 20, 2024
One of the issues with Spotless is that it's not compatible with the Gradle configuration cache. To solve this we need to use --no-configuration-cache and --no-daemon flags

- diffplug/spotless#1924
@muthuraj57
Copy link

I'm upgrading spotless from a very old version, just setting up the editorconfig file. I've spent more than a few hours on this issue, thinking why the rules are not working. When I add --no-daemon it works perfectly.

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

8 participants