GradleException when multiple goals leave behind spotless-clean dir

Open
#2,992 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
java

Research direction

Start by reproducing the sequence in the linked openapi-generator-client project: gradle clean openApiGenerate spotlessApply, followed by gradle spotlessCheck or gradle build. Inspect the generated build/spotless-clean/spotlessJava/build/generate-resources/main/src/main/java/ directory and compare behavior with a separate spotlessApply run or an explicit target; done means the subsequent check or build succeeds without manual cleanup.

Written by the indexing model from the issue text.

Description

In my project: https://github.com/sixcorners/openapi-generator-client/tree/7b2dfb9cda3fe366f0a45f76b60b1a1961311d65
If you run
gradle clean openApiGenerate spotlessApply
it leaves behind a build/spotless-clean/spotlessJava/build/generate-resources/main/src/main/java/ directory. If you then run gradle spotlessCheck or gradle build it throws an error:

Caused by: org.gradle.api.GradleException: There were 0 lint error(s), they must be fixed or suppressed.
Resolve these lints or suppress with `suppressLintsFor`
        at com.diffplug.gradle.spotless.SpotlessCheck.performAction(SpotlessCheck.java:85)
        at com.diffplug.gradle.spotless.SpotlessCheck.performAction(SpotlessCheck.java:57)

if you delete build/spotless-clean or just run gradle spotlessApply again then gradle build works again.
kind of annoying but it's not a big deal.
specifying the target manually also fixes it.

spotless {
  java {
    googleJavaFormat()
    target("src/main/java", "build/generate-resources/main/src/main/java")
  }
  kotlinGradle { ktfmt() }
}

I kind of thought the bug was something else but that disappeared so I kind of wonder if this can even be reproduced on other people's machines or if it will disappear too. It's also not a big deal since you can just run gradle spotlessApply in it's own cli invocation. Also running the build gradle goal in IntelliJ doesn't reproduce the issue. It's very fiddly. If you have trouble reproducing it I wouldn't mind if you just close this issue and leave it as a place for other people to find if they have something similar happen.
This is my gradle version running in a snap:

$ gradle --version

------------------------------------------------------------
Gradle 9.6.1
------------------------------------------------------------

Build time:    2026-06-26 14:25:50 UTC
Revision:      309d128bd9fe8c0b71311878fc660b9cbaa07c51

Kotlin:        2.3.21
Groovy:        4.0.32
Ant:           Apache Ant(TM) version 1.10.17 compiled on April 6 2026
Launcher JVM:  25.0.3 (Ubuntu 25.0.3+9-2-26.04.2-Ubuntu)
Daemon JVM:    /usr/lib/jvm/java-25-openjdk-amd64 (no Daemon JVM specified, using current Java home)
OS:            Linux 7.0.0-27-generic amd64
Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.