THRIFT-5775 Kotlin build failed for broken toolchain in docker (#3043)

* THRIFT-5775 Kotlin build failed for broken toolchain in docker

This PR adds JDK 8 to both docker containers to support the kotlin
build.
Kotlin requires toolchain 8 and cant build this without the JDK for that
language level being present.

Also correct readme since docker desktop on Mac also fixes the
permissions with volume sharing automatically.

* Remove gradle toolchains from kotlin and set source/target to java 8

* Manually set the release target for kotlin, remove overwrites from cross-test-client/server

* Set toolchain to 17 on the kotlin lib module
diff --git a/build/docker/README.md b/build/docker/README.md
index 2a338b4..9e972b8 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -135,11 +135,11 @@
 
 Build the image:
 
-Linux/Mac:
+Linux:
 
     thrift$ docker build --build-arg uid=$(id -u) --build-arg gid=$(id -g) -t thrift build/docker/ubuntu-jammy
 
-Windows:
+Windows/Mac:
 
     thrift$ docker build -t thrift build/docker/ubuntu-jammy
 
diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts
index df4a2c1..16d745b 100644
--- a/lib/kotlin/build.gradle.kts
+++ b/lib/kotlin/build.gradle.kts
@@ -16,6 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
 
 plugins {
     kotlin("jvm")
@@ -36,13 +38,19 @@
 
 kotlin {
     jvmToolchain {
-        (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8))
+        languageVersion.set(JavaLanguageVersion.of(17))
     }
 }
 
-tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
+java {
+    sourceCompatibility = JavaVersion.VERSION_1_8
+    targetCompatibility = JavaVersion.VERSION_1_8
+}
+
+tasks.withType<KotlinCompile> {
     compilerOptions {
-        jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
+        jvmTarget = JvmTarget.JVM_1_8
+        freeCompilerArgs = listOf("-Xjdk-release=1.8")
     }
 }
 
diff --git a/lib/kotlin/cross-test-client/build.gradle.kts b/lib/kotlin/cross-test-client/build.gradle.kts
index 8a2c234..c68f393 100644
--- a/lib/kotlin/cross-test-client/build.gradle.kts
+++ b/lib/kotlin/cross-test-client/build.gradle.kts
@@ -50,12 +50,6 @@
     testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
 }
 
-kotlin {
-    jvmToolchain {
-        (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8))
-    }
-}
-
 tasks {
     application {
         applicationName = "TestClient"
diff --git a/lib/kotlin/cross-test-server/build.gradle.kts b/lib/kotlin/cross-test-server/build.gradle.kts
index eda1ebd..57fef4f 100644
--- a/lib/kotlin/cross-test-server/build.gradle.kts
+++ b/lib/kotlin/cross-test-server/build.gradle.kts
@@ -48,12 +48,6 @@
     testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
 }
 
-kotlin {
-    jvmToolchain {
-        (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8))
-    }
-}
-
 tasks {
     application {
         applicationName = "TestServer"
@@ -68,7 +62,7 @@
 
     task<Exec>("compileThrift") {
         val thriftBin = if (hasProperty("thrift.compiler")) {
-            file(property("thrift.compiler"))
+            file(property("thrift.compiler")!!)
         } else {
             project.rootDir.resolve("../../compiler/cpp/thrift")
         }