spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Automatically clear gradle configuration cache and retry on stale-cache failure

Open nedtwigg opened this issue 3 years ago • 0 comments

Anywhere we throw this exception:

https://github.com/diffplug/spotless/blob/6ef9878653d8965f7a912bea4a44a081c3f06adb/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JvmLocalCache.java#L32-L36

We could instead just do the rm -rf ourselves and then use project.gradle.startParameter to reconstruct and execute the gradle invocation. (javadoc)

I think the tricky part is that you might have to launch a new JVM so that the .gradle/configuration-cache files aren't locked. It might also be tricky to reconstitute the exact command, but just an approximation with the same task names would be plenty.

This would definitely need to be gated behind something like:

spotless {
  autoRetry_issue_987 = true
}

No plan to implement this, but happy to merge a PR for it.

nedtwigg avatar May 13 '22 19:05 nedtwigg