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/build.gradle b/lib/java/build.gradle
index 3e750fd..8206411 100644
--- a/lib/java/build.gradle
+++ b/lib/java/build.gradle
@@ -37,11 +37,11 @@
 
 plugins {
     id 'java-library'
-    id 'maven'
+    id 'maven-publish'
     id 'signing'
     id 'com.github.johnrengelman.shadow' version '6.1.0'
     id "com.github.spotbugs" version "4.7.1"
-    id "com.diffplug.spotless" version "6.4.2"
+    id "com.diffplug.spotless" version "6.5.2"
 }
 
 description = 'Apache Thrift Java Library'
@@ -60,7 +60,6 @@
 // Keeping the rest of the build logic in functional named scripts for clarity
 apply from: 'gradle/environment.gradle'
 apply from: 'gradle/sourceConfiguration.gradle'
-apply from: 'gradle/additionalArtifacts.gradle'
 apply from: 'gradle/generateTestThrift.gradle'
 apply from: 'gradle/unitTests.gradle'
 apply from: 'gradle/cloverCoverage.gradle'