THRIFT-5568: enforce consistent Java formatting (#2581)

* use spotless plugin and google-java-format to enforce a consistent code format
* add a step of spotless check before building
* only run spotless on the src/ directory

Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
diff --git a/lib/java/build.gradle b/lib/java/build.gradle
index 6bd2ec4..726d7b7 100644
--- a/lib/java/build.gradle
+++ b/lib/java/build.gradle
@@ -41,6 +41,7 @@
     id 'signing'
     id 'com.github.johnrengelman.shadow' version '4.0.4'
     id "com.github.spotbugs" version "4.7.1"
+    id "com.diffplug.spotless" version "6.4.2"
 }
 
 description = 'Apache Thrift Java Library'