THRIFT-5581: use gradle 7 for java/kotlin (#2601)

* upgrade gradle version to 7.4
* migrate from `maven` plugin to `maven-publish` plugin as required for Gradle 7
* add guard to ktfmt, since it can't run with JDK 8

Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
diff --git a/lib/java/gradle/codeQualityChecks.gradle b/lib/java/gradle/codeQualityChecks.gradle
index f633413..b8d13f9 100644
--- a/lib/java/gradle/codeQualityChecks.gradle
+++ b/lib/java/gradle/codeQualityChecks.gradle
@@ -39,8 +39,8 @@
 
 tasks.withType(Pmd) {
     reports {
-        html.enabled = true
-        xml.enabled = false
+        html.required = true
+        xml.required = false
     }
 }