How to change the jdkHome argument for Kotlin comp...
# gradle
s
How to change the jdkHome argument for Kotlin compilation? I followed the guide but it is not working.
Copy code
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain

plugins {
    kotlin("jvm")
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib"))
    implementation(project(":tree-sitter"))
}

val service = project.extensions.getByType<JavaToolchainService>()
val customLauncher = service.launcherFor {
    languageVersion.set(JavaLanguageVersion.of(22))
}
project.tasks.withType<UsesKotlinJavaToolchain>().configureEach {
    kotlinJavaToolchain.toolchain.use(customLauncher)
}

kotlin {
    jvmToolchain {
        languageVersion.set(JavaLanguageVersion.of(22))
    }
    compilerOptions {
        jvmTarget.set(JvmTarget.JVM_22)

    }
}


tasks.withType<UsesKotlinJavaToolchain>().configureEach {
    kotlinJavaToolchain.jdk.use(
        "/Users/admin/.sdkman/candidates/java/22-graal",
        JavaVersion.VERSION_22
    )
}


tasks {
    withType<KotlinCompile> {
        compilerOptions {
            jvmTarget.set(JvmTarget.JVM_22)
            noJdk.set(true)
        }
    }

    compileKotlin {
        kotlinOptions {
            jvmTarget = "22"
        }

        compilerOptions {
            jvmTarget.set(JvmTarget.JVM_22)
            noJdk.set(true)
        }

    }
}
No matter how I set toolchain to use 22, the
[KOTLIN] Kotlin compilation 'jdkHome' argument:
always points to 21