Use gradle toolchains in the buildscript

This commit is contained in:
Username404 2021-06-01 11:26:34 +02:00
parent f4203bcd16
commit 3313bd7c7d
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 6 additions and 4 deletions

View File

@ -28,6 +28,7 @@ architectury {
}
val javaVer: String = "8"
val sourceJavaVer: String = "16"
val kotlinVer: String by rootProject
val kotlinBaseVer = kotlinVer.substring(0..2)
val mcBase: String = rootProject.architectury.minecraft.substring(0..3)
@ -152,9 +153,7 @@ allprojects {
apply(plugin = "java")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "architectury-plugin")
java {
sourceCompatibility = JavaVersion.VERSION_11
}
val compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(sourceJavaVer.toInt())) }
dependencies {
implementation(kotlin("stdlib-jdk8", kotlinVer))
implementation(kotlin("reflect", kotlinVer))
@ -178,12 +177,15 @@ allprojects {
with(options) {
encoding = "UTF-8"
isFork = true
release.set(javaVer.toInt())
javaCompiler.set(compiler)
// The following lines are required for Jabel:
sourceCompatibility = sourceJavaVer
forkOptions.jvmArgs!!.addAll(listOf(
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"
)) // Java 16+ support
compilerArgs.addAll(listOf("-Xplugin:jabel", "--release", javaVer))
compilerArgs.addAll(listOf("-Xplugin:jabel"))
}
}
withType(ProcessResources::class) {