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

Update to Loom 1.10 and use new prod run tasks #4349

Draft
wants to merge 2 commits into
base: 1.21.4
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ jobs:
with:
distribution: 'microsoft'
java-version: '21'
- run: mkdir run && echo "eula=true" >> run/eula.txt
- name: Run Client Gametests
uses: modmuss50/xvfb-action@v1
with:
run: ./gradlew runProductionClientGametest --stacktrace --warning-mode=fail
- run: |
curl -L -o tracy-capture https://github.com/modmuss50/tracy-utils/releases/download/0.0.2/linux-x86_64-tracy-capture
chmod +x tracy-capture
mkdir run && echo "eula=true" >> run/eula.txt
- run: ./gradlew runProductionClientGametest --stacktrace --warning-mode=fail
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test Screenshots
path: run/screenshots
- uses: actions/upload-artifact@v4
if: always()
with:
name: Tracy Profile
path: profile.tracy

server_test:
runs-on: ubuntu-22.04
Expand Down
96 changes: 21 additions & 75 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id "idea"
id "maven-publish"
id 'jacoco'
id "fabric-loom" version "1.9.2" apply false
id "fabric-loom" version "1.10.0-alpha.11" apply false
id "com.diffplug.spotless" version "6.20.0"
id "org.ajoberstar.grgit" version "5.2.2"
id "me.modmuss50.remotesign" version "0.5.0" apply false
Expand Down Expand Up @@ -249,11 +249,12 @@ allprojects {
useJUnitPlatform()
}

def resourceVersion = project.version
tasks.withType(ProcessResources).configureEach {
inputs.property "version", project.version
inputs.property "version", resourceVersion

filesMatching("fabric.mod.json") {
expand "version": project.version
expand "version": resourceVersion
}
}

Expand Down Expand Up @@ -478,94 +479,39 @@ tasks.register('coverage', JacocoReport) {
}

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

dependencies {
productionRuntime "net.fabricmc:fabric-loader:${project.loader_version}"
productionRuntime "net.fabricmc:intermediary:${project.minecraft_version}"

productionRuntimeServer "net.fabricmc:fabric-installer:${project.installer_version}:server"
productionMods project(':fabric-client-gametest-api-v1')
}

import net.fabricmc.loom.util.Platform

def productionMods = project.files(configurations.productionMods, remapJar.archiveFile, remapTestmodJar.archiveFile)

// This is very far beyond loom's API if you copy this, you're on your own.
tasks.register('runProductionClientGametest', JavaExec) {
dependsOn productionMods, downloadAssets
classpath.from configurations.productionRuntime
mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient"
workingDir = file("run")
tasks.register('runProductionClientGametest', net.fabricmc.loom.task.prod.ClientProductionRunTask) {
mods.setFrom productionMods
jvmArgs.addAll([
"-Dfabric.client.gametest",
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
])
jvmArgs.addAll(debugArgs)

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

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

if (Platform.CURRENT.operatingSystem.isMacOS()) {
jvmArgs(
"-XstartOnFirstThread"
)
if (ENV.CI) {
tracy {
tracyCapture = file("tracy-capture")
output = file("profile.tracy")
}

jvmArgs(
"-Dfabric.addMods=${productionMods.collect { it.absolutePath }.join(File.pathSeparator)}",
"-Dfabric.client.gametest",
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
)
jvmArgs(debugArgs)
}
}

tasks.register('serverPropertiesJar', Jar) {
def propsFile = file("build/tmp/install.properties")

doFirst {
propsFile.text = """\
fabric-loader-version=${project.loader_version}
game-version=${project.minecraft_version}
""".stripMargin().stripIndent()
}

archiveFileName = "test-server-properties.jar"
destinationDirectory = file("build/tmp")
from(propsFile)
}

tasks.register('runProductionAutoTestServer', JavaExec) {
dependsOn productionMods, serverPropertiesJar
classpath.from configurations.productionRuntimeServer, serverPropertiesJar
mainClass = "net.fabricmc.installer.ServerLauncher"
workingDir = file("run")

doFirst {
workingDir.mkdirs()

jvmArgs(
"-Dfabric.addMods=${productionMods.collect { it.absolutePath }.join(File.pathSeparator)}",
"-Dfabric.autoTest",
)
jvmArgs(debugArgs)

args("nogui")
}
tasks.register('runProductionAutoTestServer', net.fabricmc.loom.task.prod.ServerProductionRunTask) {
mods.setFrom productionMods
jvmArgs.add("-Dfabric.autoTest")
jvmArgs.addAll(debugArgs)
programArgs.add("nogui")
}

// Format all the gradle files
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.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down