From a53d05b9f95194b8652ce3cee5e33bdc05b03d59 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 25 Apr 2022 14:51:14 +0200 Subject: [PATCH] Upgrade spotless and use runToFixMessage for 'gradlew tidy' hint. (#834) --- build.gradle | 2 +- gradle/validation/spotless.gradle | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index cfde2a0204b..a71f8ab90a6 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ plugins { id 'de.thetaphi.forbiddenapis' version '3.3' apply false id "de.undercouch.download" version "4.1.1" apply false id "net.ltgt.errorprone" version "2.0.2" apply false - id 'com.diffplug.spotless' version "5.14.3" apply false + id 'com.diffplug.spotless' version "6.5.0" apply false } apply from: file('gradle/globals.gradle') diff --git a/gradle/validation/spotless.gradle b/gradle/validation/spotless.gradle index 860c0ca9b43..4c0257be10d 100644 --- a/gradle/validation/spotless.gradle +++ b/gradle/validation/spotless.gradle @@ -94,6 +94,11 @@ configure(project(":lucene").subprojects) { prj -> } } + // Emit a custom message about how to fix formatting errors. + tasks.matching { task -> task.name == "spotlessJavaCheck" }.configureEach { + runToFixMessage.set("\nIMPORTANT: run the top-level './gradlew tidy' to format code automatically (see help/formatting.txt for more info).") + } + // Add an alias to 'spotlessApply' simply called 'tidy' and wire up // spotlessCheck to convention's check. task tidy() { @@ -111,9 +116,3 @@ configure(project(":lucene").subprojects) { prj -> v.dependsOn ":checkJdkInternalsExportedToGradle" } } - -gradle.taskGraph.afterTask { Task task, TaskState state -> - if (task.name == 'spotlessJavaCheck' && state.failure) { - throw new GradleException("\n****************************\n*PLEASE RUN ./gradlew tidy!*\n****************************"); - } -}