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/kotlin/cross-test-server/build.gradle.kts b/lib/kotlin/cross-test-server/build.gradle.kts
index 508b29d..eda1ebd 100644
--- a/lib/kotlin/cross-test-server/build.gradle.kts
+++ b/lib/kotlin/cross-test-server/build.gradle.kts
@@ -19,9 +19,9 @@
 
 plugins {
     kotlin("jvm")
-    id("com.ncorti.ktfmt.gradle")
     java
     application
+    id("com.ncorti.ktfmt.gradle")
 }
 
 repositories {
@@ -60,8 +60,10 @@
         mainClass.set("org.apache.thrift.test.TestServerKt")
     }
 
-    ktfmt {
-        kotlinLangStyle()
+    if (JavaVersion.current().isJava11Compatible) {
+        ktfmt {
+            kotlinLangStyle()
+        }
     }
 
     task<Exec>("compileThrift") {