Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand the builtin Minecraft testing setup. #981

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
if: always()
with:
name: Client Test Screenshots
path: minecraft/minecraft-test/run/screenshots
path: minecraft/minecraft-test/run/screenshots
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ plugins {
id 'maven-publish'
id 'checkstyle'
id 'com.diffplug.spotless' version "6.22.0"
id 'fabric-loom' version '1.4-SNAPSHOT' apply false
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'fabric-loom' version '1.7-SNAPSHOT' apply false
id 'com.gradleup.shadow' version '8.3.2'
id 'me.modmuss50.remotesign' version "0.4.0"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
12 changes: 7 additions & 5 deletions minecraft/minecraft-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Ignore everything
/*
/.gradle
/build
/run

!/src
!/build.gradle
!/.gitignore
versions/build
versions/*/build
versions/*/.gradle
versions/*/run
5 changes: 5 additions & 0 deletions minecraft/minecraft-test/versions/1.12.2/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"minecraftVersion": "1.12.2",
"javaVersion": 8,
"hasIntermediary": false
}
4 changes: 4 additions & 0 deletions minecraft/minecraft-test/versions/1.16.5/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"minecraftVersion": "1.16.5",
"javaVersion": 8
}
6 changes: 6 additions & 0 deletions minecraft/minecraft-test/versions/1.2.5/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"minecraftVersion": "1.2.5",
"javaVersion": 8,
"hasIntermediary": false,
"mergedJars": false
}
423 changes: 423 additions & 0 deletions minecraft/minecraft-test/versions/1.20.1/meta.json

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions minecraft/minecraft-test/versions/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import groovy.json.JsonSlurper

subprojects {
def meta = new JsonSlurper().parse(file("meta.json"))
def minecraftVersion = meta.minecraftVersion
def hasIntermediary = meta.hasIntermediary == null ? true : meta.hasIntermediary
def mergedJars = meta.mergedJars == null ? true : meta.mergedJars
def mods = meta.mods == null ? [] : meta.mods

apply plugin: "fabric-loom"

loom {
if (!hasIntermediary) {
noIntermediateMappings()
}

if (!mergedJars) {
clientOnlyMinecraftJar()
}
}

configurations {
productionRuntime {
extendsFrom configurations.minecraftLibraries
extendsFrom configurations.loaderLibraries
extendsFrom configurations.minecraftRuntimeLibraries
}
productionRuntimeMods {
transitive = false
}
}

repositories {
exclusiveContent {
forRepository {
maven {
name = "CurseForge"
url = "https://cursemaven.com"
}
}
filter {
includeGroup "curse.maven"
}
}
}

dependencies {
minecraft "com.mojang:minecraft:$minecraftVersion"
mappings loom.layered() {
// We dont need mappings
}

if (hasIntermediary) {
productionRuntime "net.fabricmc:intermediary:$minecraftVersion"
}

// Add the launcher libraries to the classpath
def installerJson = new JsonSlurper().parse(rootProject.file("src/main/resources/fabric-installer.json"))
installerJson.libraries.common.each {
productionRuntime it.name
}

mods.each {
productionRuntimeMods it
}
}

// Generate a a list of mod paths so we dont hit the command line length limit on windows
def modsListFile = tasks.register("modsListFile") {
inputs.files configurations.productionRuntime
outputs.file(layout.buildDirectory.file("mods.txt"))
doLast {
file(layout.buildDirectory.file("mods.txt").get().asFile).text = configurations.productionRuntimeMods.files.join("\n")
}
}

def loaderJarTask = project(":").tasks.proguardJar

def runProductionClient = tasks.register("runProductionClient", JavaExec) {
dependsOn modsListFile
classpath.from configurations.productionRuntime
classpath.from loaderJarTask
mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient"
workingDir = file("run")
group = "test"

javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(meta.javaVersion)
}

doFirst {
classpath.from loom.minecraftProvider.minecraftClientJar
workingDir.mkdirs()

def optionsTxt = new File(workingDir, "options.txt")

if (!optionsTxt.exists()) {
optionsTxt.text = "onboardAccessibility:false\n"
}

args(
"--assetIndex", loom.minecraftProvider.versionInfo.assetIndex().fabricId(loom.minecraftProvider.minecraftVersion()),
"--assetsDir", new File(loom.files.userCache, "assets").absolutePath,
"--gameDir", workingDir.absolutePath
)

if (net.fabricmc.loom.util.Platform.CURRENT.operatingSystem.isMacOS()) {
jvmArgs(
"-XstartOnFirstThread"
)
}

if (loom.minecraftProvider.versionInfo.hasNativesToExtract()) {
def nativesPath = loom.files.getNativesDirectory(project).getAbsolutePath()
systemProperty("java.library.path", nativesPath)
systemProperty("org.lwjgl.librarypath", nativesPath)
}

jvmArgs(
"-Dfabric.addMods=@${tasks.modsListFile.outputs.files.singleFile.absolutePath}"
)
}
}

if (meta.modpack != null) {
configurations {
modpack
}

dependencies {
modpack meta.modpack
}

tasks.register("extractModpack", Copy) {
from(zipTree(configurations.modpack.singleFile)) {
include "overrides/**"
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
into runProductionClient.get().workingDir
group = "test"
}

runProductionClient.configure {
dependsOn extractModpack
}
}

afterEvaluate {
runProductionClient.configure {
dependsOn downloadAssets

if (loom.minecraftProvider.versionInfo.hasNativesToExtract()) {
dependsOn extractNatives
}
}
}
}
1 change: 1 addition & 0 deletions minecraft/minecraft-test/versions/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fabric.loom.dontRemap=true
8 changes: 7 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {

include "minecraft"
include "junit"
include "minecraft:minecraft-test"
include "minecraft:minecraft-test"

file("minecraft/minecraft-test/versions").listFiles().each { file ->
if (file.isDirectory() && new File(file, "meta.json").exists()) {
include("minecraft:minecraft-test:versions:${file.name}")
}
}
Loading