From 82a4e85bc583396b7e32fce33d2a68a5d2332b07 Mon Sep 17 00:00:00 2001 From: zml Date: Tue, 23 Jan 2024 19:03:35 -0800 Subject: [PATCH] chore(build): Derive our java target from what the API declares --- SpongeAPI | 2 +- build.gradle.kts | 12 +++++++----- vanilla/build.gradle.kts | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/SpongeAPI b/SpongeAPI index 78d22fb9206..ed34adb06eb 160000 --- a/SpongeAPI +++ b/SpongeAPI @@ -1 +1 @@ -Subproject commit 78d22fb9206ceb247457cb9e4fcddf8df00c3fd0 +Subproject commit ed34adb06ebdda706d0a2407c18631cc3f9915a5 diff --git a/build.gradle.kts b/build.gradle.kts index f9ceef41ea4..873074f4b03 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,7 @@ plugins { val commonProject = project val apiVersion: String by project +val apiJavaTarget: String by project val minecraftVersion: String by project val recommendedVersion: String by project @@ -307,11 +308,12 @@ allprojects { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - if (JavaVersion.current() < JavaVersion.VERSION_17) { + val targetJavaVersion = JavaVersion.toVersion(apiJavaTarget.toInt()) + sourceCompatibility = targetJavaVersion + targetCompatibility = targetJavaVersion + if (JavaVersion.current() < targetJavaVersion) { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(apiJavaTarget.toInt())) } } } @@ -345,7 +347,7 @@ allprojects { withType(JavaCompile::class).configureEach { options.compilerArgs.addAll(listOf("-Xmaxerrs", "1000")) options.encoding = "UTF-8" - options.release.set(17) + options.release.set(apiJavaTarget.toInt()) if (project.name != "testplugins" && System.getProperty("idea.sync.active") != null) { options.annotationProcessorPath = emptyAnnotationProcessors // hack so IntelliJ doesn't try to run Mixin AP } diff --git a/vanilla/build.gradle.kts b/vanilla/build.gradle.kts index e957fa664e3..2cb6d073e1c 100644 --- a/vanilla/build.gradle.kts +++ b/vanilla/build.gradle.kts @@ -8,6 +8,7 @@ plugins { val commonProject = parent!! val apiVersion: String by project +val apiJavaTarget: String by project val minecraftVersion: String by project val recommendedVersion: String by project val organization: String by project @@ -66,7 +67,7 @@ val vanillaInstallerJava9 by sourceSets.register("installerJava9") { sequenceOf(runtimeClasspathConfigurationName, compileClasspathConfigurationName).map(configurations::named).forEach { it.configure { attributes { - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, apiJavaTarget.toInt()) } } } @@ -180,7 +181,7 @@ minecraft { } configureEach { - targetVersion(17) + targetVersion(apiJavaTarget.toInt()) workingDirectory(project.file("run/")) if (org.spongepowered.gradle.vanilla.internal.util.IdeConfigurer.isIdeaImport()) { // todo(zml): promote to API... eventually // IntelliJ does not properly report its compatibility