spotless icon indicating copy to clipboard operation
spotless copied to clipboard

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

Open 0legg opened this issue 1 year ago • 9 comments

  • [x] 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.

  • [x] Gradle or Maven version Gradle 8.4, 8.5

  • [x] spotless version Spotless 6.23.1

  • [x] operating system and version macos Sonoma, 14.1.1

0legg avatar Dec 01 '23 22:12 0legg

Seems I've experienced this issue.

Goooler avatar Dec 02 '23 04:12 Goooler

By some coincidence issues like https://github.com/diffplug/spotless/issues/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.

0legg avatar Dec 02 '23 04:12 0legg

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.

galiren avatar Jan 01 '24 14:01 galiren

@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.

0legg avatar Jan 12 '24 18:01 0legg

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

Goooler avatar Jan 13 '24 04:01 Goooler

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?

stkent avatar Mar 28 '24 15:03 stkent

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.

TWiStErRob avatar May 04 '24 09:05 TWiStErRob

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

madorb avatar Jun 06 '24 13:06 madorb