From 1d63799f9646ae6a42a642ff5206103ad3269cf2 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Tue, 3 May 2022 21:14:24 +0800 Subject: [PATCH] HBASE-26892 Add spotless:check in our pre commit general check (#4393) Signed-off-by: Nick Dimiduk (cherry picked from commit 386869a428bc6256d44436cd4cd5d668a919aacd) --- dev-support/hbase-personality.sh | 49 ++++++++++++++++++++++++++++++++ pom.xml | 4 +++ 2 files changed, 53 insertions(+) diff --git a/dev-support/hbase-personality.sh b/dev-support/hbase-personality.sh index 313ff42cd84..081ee5aaa4d 100755 --- a/dev-support/hbase-personality.sh +++ b/dev-support/hbase-personality.sh @@ -869,6 +869,55 @@ function hbaseanti_patchfile return 0 } +###################################### + +add_test_type spotless + +## @description spotless file filter +## @audience private +## @stability evolving +## @param filename +function spotless_filefilter +{ + # always add spotless check as it can format almost all types of files + add_test spotless +} +## @description run spotless:check to check format issues +## @audience private +## @stability evolving +## @param repostatus +function spotless_rebuild +{ + local repostatus=$1 + local logfile="${PATCH_DIR}/${repostatus}-spotless.txt" + + if ! verify_needed_test spotless; then + return 0 + fi + + big_console_header "Checking spotless on ${repostatus}" + + start_clock + + local -a maven_args=('spotless:check') + + # disabled because "maven_executor" needs to return both command and args + # shellcheck disable=2046 + echo_and_redirect "${logfile}" $(maven_executor) "${maven_args[@]}" + + count=$(${GREP} -c '\[ERROR\]' "${logfile}") + if [[ ${count} -gt 0 ]]; then + add_vote_table -1 spotless "${repostatus} has ${count} errors when running spotless:check, run spotless:apply to fix." + add_footer_table spotless "@@BASE@@/${repostatus}-spotless.txt" + return 1 + fi + + add_vote_table +1 spotless "${repostatus} has no errors when running spotless:check." + return 0 +} + +###################################### + ## @description process the javac output for generating WARNING/ERROR ## @audience private ## @stability evolving diff --git a/pom.xml b/pom.xml index 28869af4420..d57a8dc487d 100755 --- a/pom.xml +++ b/pom.xml @@ -2246,6 +2246,10 @@ **/*.txt *.txt + + **/target/** + **/dependency-reduced-pom.xml +