From c57c381688676a358e95812fab596fc28dbf60c1 Mon Sep 17 00:00:00 2001 From: veyndan Date: Fri, 8 Aug 2025 17:47:15 +0200 Subject: [PATCH 1/3] State `./gradlew spotlessApply` fixes all issues in error message --- plugin-gradle/CHANGES.md | 1 + .../java/com/diffplug/gradle/spotless/SpotlessCheck.java | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 9e25b1d3d3..fa90cd957e 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -9,6 +9,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Adds support for worktrees (fixes [#1765](https://github.com/diffplug/spotless/issues/1765)) * Bump default `google-java-format` version to latest `1.24.0` -> `1.28.0`. ([#2345](https://github.com/diffplug/spotless/pull/2345)) * Bump default `ktlint` version to latest `1.5.0` -> `1.7.1`. ([#2555](https://github.com/diffplug/spotless/pull/2555)) +* Running `spotlessCheck` with violations unilaterally produces the error message `Run './gradlew spotlessApply' to fix these violations`. ([#2592](https://github.com/diffplug/spotless/issues/2592)) ### Fixed * Respect system gitconfig when performing git operations ([#2404](https://github.com/diffplug/spotless/issues/2404)) diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java index 175a828a66..fdc93ce04a 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java @@ -138,12 +138,7 @@ void init(SpotlessTaskImpl impl) { getProjectPath().set(getProject().getPath()); getEncoding().set(impl.getEncoding()); getRunToFixMessage().convention( - "Run '" + calculateGradleCommand() + " " + getTaskPathPrefix() + "spotlessApply' to fix these violations."); - } - - private String getTaskPathPrefix() { - String path = getProjectPath().get(); - return path.equals(":") ? ":" : path + ":"; + "Run '" + calculateGradleCommand() + " spotlessApply' to fix all violations."); } private static String calculateGradleCommand() { From 3aa94b36c8bd2759345022bcfe94a1edb9294c57 Mon Sep 17 00:00:00 2001 From: veyndan Date: Sun, 10 Aug 2025 17:28:50 +0200 Subject: [PATCH 2/3] Update Gradle task from `spotlessApply` to `:spotlessApply` --- .../main/java/com/diffplug/gradle/spotless/SpotlessCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java index fdc93ce04a..9b798eb528 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java @@ -138,7 +138,7 @@ void init(SpotlessTaskImpl impl) { getProjectPath().set(getProject().getPath()); getEncoding().set(impl.getEncoding()); getRunToFixMessage().convention( - "Run '" + calculateGradleCommand() + " spotlessApply' to fix all violations."); + "Run '" + calculateGradleCommand() + " :spotlessApply' to fix all violations."); } private static String calculateGradleCommand() { From 8d10ea5b64f5beb674f7b57669a85ee33b937c6f Mon Sep 17 00:00:00 2001 From: veyndan Date: Sun, 17 Aug 2025 16:13:11 +0100 Subject: [PATCH 3/3] Revert "Update Gradle task from `spotlessApply` to `:spotlessApply`" This reverts commit 3aa94b36c8bd2759345022bcfe94a1edb9294c57. --- .../main/java/com/diffplug/gradle/spotless/SpotlessCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java index 9b798eb528..fdc93ce04a 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessCheck.java @@ -138,7 +138,7 @@ void init(SpotlessTaskImpl impl) { getProjectPath().set(getProject().getPath()); getEncoding().set(impl.getEncoding()); getRunToFixMessage().convention( - "Run '" + calculateGradleCommand() + " :spotlessApply' to fix all violations."); + "Run '" + calculateGradleCommand() + " spotlessApply' to fix all violations."); } private static String calculateGradleCommand() {