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-client/build.gradle.kts b/lib/kotlin/cross-test-client/build.gradle.kts
index deda467..ff48eed 100644
--- a/lib/kotlin/cross-test-client/build.gradle.kts
+++ b/lib/kotlin/cross-test-client/build.gradle.kts
@@ -19,9 +19,9 @@
 
 plugins {
     kotlin("jvm")
-    id("com.ncorti.ktfmt.gradle")
     java
     application
+    id("com.ncorti.ktfmt.gradle")
 }
 
 repositories {
@@ -62,8 +62,10 @@
         mainClass.set("org.apache.thrift.test.TestClientKt")
     }
 
-    ktfmt {
-        kotlinLangStyle()
+    if (JavaVersion.current().isJava11Compatible) {
+        ktfmt {
+            kotlinLangStyle()
+        }
     }
 
     task<Exec>("compileThrift") {
diff --git a/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt b/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt
index 28f9ffd..39500df 100644
--- a/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt
+++ b/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt
@@ -77,30 +77,27 @@
 }
 
 class TestClient : CliktCommand() {
-    private val host: String by option(help = "The cross test host to connect to")
-        .default("localhost")
+    private val host: String by
+        option(help = "The cross test host to connect to").default("localhost")
     private val port: Int by option(help = "The cross test port to connect to").int().default(9090)
-    private val numTests: Int by option("--testloops", "--n", help = "Number of runs in this test")
-        .int()
-        .default(1)
-    private val protocolType: ProtocolType by option("--protocol", help = "Protocol type")
-        .enum<ProtocolType> { it.key }
-        .default(ProtocolType.Binary)
-    private val transportType: TransportType by option("--transport", help = "Transport type")
-        .enum<TransportType> { it.key }
-        .default(TransportType.Buffered)
-    private val useHttpClient: Boolean by option("--client", help = "Use http client")
-        .flag(default = false)
-    private val useSSL: Boolean by option("--ssl", help = "Use SSL for encrypted transport")
-        .flag(default = false)
-    private val useZlib: Boolean by option(
-            "--zlib",
-            help = "Use zlib wrapper for compressed transport"
-        )
-        .flag(default = false)
-    private val socketTimeout: Int by option("--timeout", help = "Socket timeout")
-        .int()
-        .default(1000)
+    private val numTests: Int by
+        option("--testloops", "--n", help = "Number of runs in this test").int().default(1)
+    private val protocolType: ProtocolType by
+        option("--protocol", help = "Protocol type")
+            .enum<ProtocolType> { it.key }
+            .default(ProtocolType.Binary)
+    private val transportType: TransportType by
+        option("--transport", help = "Transport type")
+            .enum<TransportType> { it.key }
+            .default(TransportType.Buffered)
+    private val useHttpClient: Boolean by
+        option("--client", help = "Use http client").flag(default = false)
+    private val useSSL: Boolean by
+        option("--ssl", help = "Use SSL for encrypted transport").flag(default = false)
+    private val useZlib: Boolean by
+        option("--zlib", help = "Use zlib wrapper for compressed transport").flag(default = false)
+    private val socketTimeout: Int by
+        option("--timeout", help = "Socket timeout").int().default(1000)
 
     private fun createProtocol(transport: TTransport): TProtocol =
         when (protocolType) {