Skip to content

Commit

Permalink
Add Java version to forge/simple test variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Nov 15, 2023
1 parent 4d22f38 commit d765178
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"() {
Expand All @@ -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 {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 5 additions & 6 deletions src/test/resources/projects/forge/simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d765178

Please sign in to comment.