Specify JDK toolchain directly

Specifying JDK toolchain in the java block lets us avoid specifying
same version again and again for different options while ensuring everything
is on the same version

Ref: https://developer.android.com/build/jdks#toolchain

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2025-10-25 00:41:13 +08:00
parent 2543c32231
commit b279e14d29

View File

@@ -9,7 +9,6 @@
import com.google.devtools.ksp.KspExperimental
import java.util.Properties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.android.application)
@@ -28,10 +27,14 @@ val lastCommitHash = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.map { it.trim() }
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
kotlin {
jvmToolchain(21)
compilerOptions {
jvmTarget = JvmTarget.JVM_21
freeCompilerArgs.addAll(
"-Xannotation-default-target=param-property"
)
@@ -140,11 +143,6 @@ android {
compose = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
lint {
lintConfig = file("lint.xml")
}