Upgrade spotless and use runToFixMessage for 'gradlew tidy' hint. (#834)

This commit is contained in:
Dawid Weiss 2022-04-25 14:51:14 +02:00 committed by GitHub
parent 2080caff3f
commit a53d05b9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -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')

View File

@ -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****************************");
}
}