From d765178d836b965e6add5283fc00f97cb34027ca Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Thu, 16 Nov 2023 01:24:14 +0200 Subject: [PATCH] Add Java version to forge/simple test variables --- .../forge/ForgeRunConfigTest.groovy | 14 +++++---- .../test/integration/forge/ForgeTest.groovy | 29 ++++++++++--------- .../forge/PatchedDecompileTest.groovy | 9 +++--- .../neoforge/NeoForge1201Test.groovy | 1 + .../projects/forge/simple/build.gradle | 11 ++++--- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeRunConfigTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeRunConfigTest.groovy index f845d7ac0..43e9b447f 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeRunConfigTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeRunConfigTest.groovy @@ -42,6 +42,7 @@ class ForgeRunConfigTest extends Specification implements GradleProjectTestTrait .replace('@MAPPINGS@', 'loom.officialMojangMappings()') .replace('@REPOSITORIES@', '') .replace('@PACKAGE@', 'net.minecraftforge:forge') + .replace('@JAVA_VERSION@', javaVersion) gradle.buildGradle << """ tasks.register('verifyRunConfigs') { doLast { @@ -64,12 +65,12 @@ class ForgeRunConfigTest extends Specification implements GradleProjectTestTrait result.task(":verifyRunConfigs").outcome == SUCCESS where: - mcVersion | forgeVersion | mainClass - '1.19.4' | "45.0.43" | 'cpw.mods.bootstraplauncher.BootstrapLauncher' - '1.18.1' | "39.0.63" | 'cpw.mods.bootstraplauncher.BootstrapLauncher' - '1.17.1' | "37.0.67" | 'cpw.mods.bootstraplauncher.BootstrapLauncher' - '1.16.5' | "36.2.4" | 'net.minecraftforge.userdev.LaunchTesting' - '1.14.4' | "28.2.23" | 'net.minecraftforge.userdev.LaunchTesting' + mcVersion | forgeVersion | javaVersion | mainClass + '1.19.4' | "45.0.43" | '17' | 'cpw.mods.bootstraplauncher.BootstrapLauncher' + '1.18.1' | "39.0.63" | '17' | 'cpw.mods.bootstraplauncher.BootstrapLauncher' + '1.17.1' | "37.0.67" | '16' | 'cpw.mods.bootstraplauncher.BootstrapLauncher' + '1.16.5' | "36.2.4" | '8' | 'net.minecraftforge.userdev.LaunchTesting' + '1.14.4' | "28.2.23" | '8' | 'net.minecraftforge.userdev.LaunchTesting' } def "verify mod classes"() { @@ -80,6 +81,7 @@ class ForgeRunConfigTest extends Specification implements GradleProjectTestTrait .replace('@MAPPINGS@', 'loom.officialMojangMappings()') .replace('@REPOSITORIES@', '') .replace('@PACKAGE@', 'net.minecraftforge:forge') + .replace('@JAVA_VERSION@', '17') gradle.buildGradle << ''' sourceSets { testMod {} diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeTest.groovy index 7bd14046b..c4c0edebf 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/forge/ForgeTest.groovy @@ -42,6 +42,7 @@ class ForgeTest extends Specification implements GradleProjectTestTrait { .replace('@MAPPINGS@', mappings) .replace('@REPOSITORIES@', '') .replace('@PACKAGE@', 'net.minecraftforge:forge') + .replace('@JAVA_VERSION@', javaVersion) when: def result = gradle.run(task: "build") @@ -50,19 +51,19 @@ class ForgeTest extends Specification implements GradleProjectTestTrait { result.task(":build").outcome == SUCCESS where: - mcVersion | forgeVersion | mappings - '1.20.1' | "47.2.1" | "loom.officialMojangMappings()" - '1.20.1' | "47.2.1" | "'net.fabricmc:yarn:1.19.4+build.2:v2'" - '1.19.4' | "45.0.43" | "loom.officialMojangMappings()" - '1.19.4' | "45.0.43" | "'net.fabricmc:yarn:1.19.4+build.2:v2'" - '1.18.1' | "39.0.63" | "loom.officialMojangMappings()" - '1.18.1' | "39.0.63" | '"net.fabricmc:yarn:1.18.1+build.22:v2"' - '1.17.1' | "37.0.67" | "loom.officialMojangMappings()" - '1.17.1' | "37.0.67" | '"net.fabricmc:yarn:1.17.1+build.61:v2"' - '1.16.5' | "36.2.4" | "loom.officialMojangMappings()" - '1.16.5' | "36.2.4" | '"net.fabricmc:yarn:1.16.5+build.5:v2"' - '1.16.5' | '36.2.4' | '"de.oceanlabs.mcp:mcp_snapshot:20210309-1.16.5"' - '1.14.4' | "28.2.23" | "loom.officialMojangMappings()" - '1.14.4' | "28.2.23" | '"net.fabricmc:yarn:1.14.4+build.18:v2"' + mcVersion | forgeVersion | javaVersion | mappings + '1.20.1' | "47.2.1" | '17' | "loom.officialMojangMappings()" + '1.20.1' | "47.2.1" | '17' | "'net.fabricmc:yarn:1.19.4+build.2:v2'" + '1.19.4' | "45.0.43" | '17' | "loom.officialMojangMappings()" + '1.19.4' | "45.0.43" | '17' | "'net.fabricmc:yarn:1.19.4+build.2:v2'" + '1.18.1' | "39.0.63" | '17' | "loom.officialMojangMappings()" + '1.18.1' | "39.0.63" | '17' | '"net.fabricmc:yarn:1.18.1+build.22:v2"' + '1.17.1' | "37.0.67" | '16' | "loom.officialMojangMappings()" + '1.17.1' | "37.0.67" | '16' | '"net.fabricmc:yarn:1.17.1+build.61:v2"' + '1.16.5' | "36.2.4" | '8' | "loom.officialMojangMappings()" + '1.16.5' | "36.2.4" | '8' | '"net.fabricmc:yarn:1.16.5+build.5:v2"' + '1.16.5' | '36.2.4' | '8' | '"de.oceanlabs.mcp:mcp_snapshot:20210309-1.16.5"' + '1.14.4' | "28.2.23" | '8' | "loom.officialMojangMappings()" + '1.14.4' | "28.2.23" | '8' | '"net.fabricmc:yarn:1.14.4+build.18:v2"' } } diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/forge/PatchedDecompileTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/forge/PatchedDecompileTest.groovy index a3a17af35..38d68cafc 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/forge/PatchedDecompileTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/forge/PatchedDecompileTest.groovy @@ -42,6 +42,7 @@ class PatchedDecompileTest extends Specification implements GradleProjectTestTra .replace('@MAPPINGS@', 'loom.officialMojangMappings()') .replace('@REPOSITORIES@', '') .replace('@PACKAGE@', 'net.minecraftforge:forge') + .replace('@JAVA_VERSION@', javaVersion) when: def result = gradle.run(task: "genForgePatchedSources") @@ -50,9 +51,9 @@ class PatchedDecompileTest extends Specification implements GradleProjectTestTra result.task(":genForgePatchedSources").outcome == SUCCESS where: - mcVersion | forgeVersion - '1.19.2' | "43.1.1" - '1.18.1' | "39.0.63" - '1.17.1' | "37.0.67" + mcVersion | forgeVersion | javaVersion + '1.19.2' | "43.1.1" | '17' + '1.18.1' | "39.0.63" | '17' + '1.17.1' | "37.0.67" | '16' } } diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/neoforge/NeoForge1201Test.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/neoforge/NeoForge1201Test.groovy index ca10dd186..6c5a82c1b 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/neoforge/NeoForge1201Test.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/neoforge/NeoForge1201Test.groovy @@ -42,6 +42,7 @@ class NeoForge1201Test extends Specification implements GradleProjectTestTrait { .replace('@MAPPINGS@', mappings) .replace('@REPOSITORIES@', 'maven { url "https://maven.neoforged.net/releases/" }') .replace('@PACKAGE@', 'net.neoforged:forge') + .replace('@JAVA_VERSION@', '17') when: def result = gradle.run(task: "build") diff --git a/src/test/resources/projects/forge/simple/build.gradle b/src/test/resources/projects/forge/simple/build.gradle index 895a65ce2..844f05b6b 100644 --- a/src/test/resources/projects/forge/simple/build.gradle +++ b/src/test/resources/projects/forge/simple/build.gradle @@ -3,9 +3,11 @@ plugins { id 'maven-publish' } +def javaVersion = @JAVA_VERSION@ + java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.toVersion(javaVersion) + targetCompatibility = JavaVersion.toVersion(javaVersion) } base { @@ -45,10 +47,7 @@ tasks.withType(JavaCompile).configureEach { // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } + it.options.release = javaVersion } java {