THRIFT-5584: use gradle toolchain to specify Java 11 with --release 8 (#2606)

* use gradle toolchain to specify Java 11 with --release 8
* use newer syntax
* fix spotless apply
* remove legacy apply and bump version of spot bugs
* migrate pmd to new plugin syntax
diff --git a/lib/java/gradle/environment.gradle b/lib/java/gradle/environment.gradle
index 224f10f..f25f3e6 100644
--- a/lib/java/gradle/environment.gradle
+++ b/lib/java/gradle/environment.gradle
@@ -29,13 +29,8 @@
 ext.installPath = property('install.path')
 ext.installJavadocPath = property('install.javadoc.path')
 
-ext.thriftRoot = file('../..')
-
-if (hasProperty('thrift.compiler')) {
-    ext.thriftCompiler = property('thrift.compiler')
-} else {
-    ext.thriftCompiler = "$thriftRoot/compiler/cpp/thrift"
-}
+ext.thriftRoot = rootProject.file('../..')
+ext.thriftCompiler = findProperty('thrift.compiler') ?: "$thriftRoot/compiler/cpp/thrift"
 
 ext.mvnRepo = property('mvn.repo')
 ext.apacheRepo = property('apache.repo')
@@ -50,6 +45,7 @@
 ext.junitVersion = property('junit.version')
 ext.mockitoVersion = property('mockito.version')
 ext.javaxAnnotationVersion = property('javax.annotation.version')
+ext.commonsLang3Version = property('commons-lang3.version')
 
 // In this section you declare where to find the dependencies of your project
 repositories {
@@ -69,7 +65,7 @@
     implementation "org.apache.httpcomponents:httpcore:${httpcoreVersion}"
     implementation "javax.servlet:javax.servlet-api:${servletVersion}"
     implementation "javax.annotation:javax.annotation-api:${javaxAnnotationVersion}"
-    implementation "org.apache.commons:commons-lang3:3.12.0"
+    implementation "org.apache.commons:commons-lang3:${commonsLang3Version}"
 
     testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
     testImplementation "org.mockito:mockito-all:${mockitoVersion}"