diffplug / diffplug/spotless

NoClassDefFoundErrors when Gradle Configuration Cache is enabled

Open
#2,850 15 comments 17 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
559
Avg merge
1d 13h
Merged PRs (30d)
34

Description

When the Gradle Configuration Cache is enabled, I see intermittent `java.lang.NoClassDefFoundError` for googleJavaFormat classes for tasks like ` removeUnusedImports()`, or `org.eclipse.jdt` classes when using the `eclipse()` formatter.

Spotless Gradle Plugin: 8.2.1
Gradle Wrapper: 9.3.0
Java: observed on 21 and 25

In my observations, I have only seen issues when the project has multiple modules, and only when running a command including clean. `./gradlew clean` and `./gradlew build` work in isolation, but when running `./gradlew clean build` for instance, it results in an error similar to below when running it multiple times in a row.

```
Execution failed for task ':server:spotlessJavaCheck'.
> There were 1 lint error(s), they must be fixed or suppressed.
src/main/java/com/test/Main.java:LINE_UNDEFINED removeUnusedImports(java.lang.NoClassDefFoundError) com/google/googlejavaformat/java/RemoveUnusedImports (...)
Resolve these lints or suppress with `suppressLintsFor`
```

I've attached a minimal reproduction zip:
[spotless-cache-repro-master.zip](https://github.com/user-attachments/files/25214993/spotless-cache-repro-master.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.