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/build/docker/ubuntu-xenial/Dockerfile b/build/docker/ubuntu-xenial/Dockerfile
index 637fa25..7c523b4 100644
--- a/build/docker/ubuntu-xenial/Dockerfile
+++ b/build/docker/ubuntu-xenial/Dockerfile
@@ -155,7 +155,7 @@
     haxelib install --always hxcpp 3.4.64 2>&1 > /dev/null
 # note: hxcpp 3.4.185 (latest) no longer ships static libraries, and caused a build failure
 
-ENV GRADLE_VERSION="6.9.2"
+ENV GRADLE_VERSION="7.4.2"
 RUN apt-get install -y --no-install-recommends \
 `# Java dependencies` \
       ant \
@@ -165,7 +165,7 @@
       unzip && \
 `# Gradle` \
       wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \
-      (echo "8b356fd8702d5ffa2e066ed0be45a023a779bba4dd1a68fd11bc2a6bdc981e8f  /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \
+      (echo "29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda  /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \
       unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \
       mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \
       ln -s /usr/local/gradle/bin/gradle /usr/local/bin