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-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile
index 134d3ef..4518df7 100644
--- a/build/docker/ubuntu-bionic/Dockerfile
+++ b/build/docker/ubuntu-bionic/Dockerfile
@@ -149,7 +149,7 @@
     haxelib setup --always /usr/share/haxe/lib && \
     haxelib install --always hxcpp 2>&1 > /dev/null
 
-ENV GRADLE_VERSION="6.9.2"
+ENV GRADLE_VERSION="7.4.2"
 RUN apt-get install -y --no-install-recommends \
 `# Java dependencies` \
       ant \
@@ -158,7 +158,7 @@
       openjdk-11-jdk-headless && \
 `# 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