From 0a667a75520cece091719f13ef1644666a054db6 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 24 Nov 2021 13:27:16 -0800 Subject: [PATCH] Update server build file --- build.gradle.kts | 1 + ...pport-for-hex-color-codes-in-console.patch | 12 --------- patches/server/Build-system-changes.patch | 11 ++------ ...ktraces-in-log-messages-crash-report.patch | 21 +++++++--------- patches/server/Setup-Gradle-project.patch | 25 ++++++++----------- 5 files changed, 23 insertions(+), 47 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f67bc31eb9..ab9ef4e8cf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -87,6 +87,7 @@ tasks.generateDevelopmentBundle { "https://repo.maven.apache.org/maven2/", "https://libraries.minecraft.net/", "https://papermc.io/repo/repository/maven-public/", + "https://maven.fabricmc.net/", ) } diff --git a/patches/server/Add-support-for-hex-color-codes-in-console.patch b/patches/server/Add-support-for-hex-color-codes-in-console.patch index cb425ecbe0..ca4d56563e 100644 --- a/patches/server/Add-support-for-hex-color-codes-in-console.patch +++ b/patches/server/Add-support-for-hex-color-codes-in-console.patch @@ -5,18 +5,6 @@ Subject: [PATCH] Add support for hex color codes in console Converts upstream's hex color code legacy format into actual hex color codes in the console. -diff --git a/build.gradle.kts b/build.gradle.kts -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -0,0 +0,0 @@ dependencies { - Scanning takes about 1-2 seconds so adding this speeds up the server start. - */ - implementation("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - implementation -+ annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for out hex color converter plugin - // Paper end - implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper - implementation("org.ow2.asm:asm:9.2") diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index 2bf0bc41b7..99d620d478 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -21,14 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 implementation("com.googlecode.json-simple:json-simple:1.1.1") { // This includes junit transitively for whatever reason isTransitive = false -@@ -0,0 +0,0 @@ tasks.jar { - "Specification-Title" to "Bukkit", - "Specification-Version" to project.version, - "Specification-Vendor" to "Bukkit Team", -+ "Multi-Release" to "true", // Paper - ) - for (tld in setOf("net", "com", "org")) { - attributes("$tld/bukkit", "Sealed" to true) @@ -0,0 +0,0 @@ relocation { } } @@ -36,9 +28,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +val generatePom = tasks.named("generatePomFileForMavenPublication") + tasks.shadowJar { + configurations = listOf(project.configurations.vanillaServer.get()) archiveClassifier.set("mojang-mapped") -+ // Needed for Paperclip's install to maven local feature ++ // Needed for Paperclip's install to maven local feature // todo: are we keeping this? if so is this still correct? + from(generatePom) { + into("META-INF/maven/io.papermc.paper/paper") + rename { "pom.xml" } diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index eae524289c..27c63f374f 100644 --- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -10,11 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ - import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer - import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer +import io.papermc.paperweight.tasks.BaseTask import io.papermc.paperweight.util.* - import shadow.org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor.PLUGIN_CACHE_FILE +import java.nio.file.Files import java.util.Locale @@ -31,6 +28,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } dependencies { +@@ -0,0 +0,0 @@ dependencies { + Scanning takes about 1-2 seconds so adding this speeds up the server start. + */ + implementation("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - implementation ++ annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for our Log4j plugins + // Paper end + implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper + implementation("org.ow2.asm:asm:9.2") @@ -0,0 +0,0 @@ dependencies { runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0") runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.0") @@ -40,16 +45,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 testImplementation("junit:junit:4.13.1") testImplementation("org.hamcrest:hamcrest-library:1.3") } -@@ -0,0 +0,0 @@ relocation { - relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$packageVersion") { - exclude("org.bukkit.craftbukkit.Main*") - } -+ relocate("net.fabricmc.mapping-io" to "io.papermc.dependency.mappingio") // Paper - } - - val generatePom = tasks.named("generatePomFileForMavenPublication") @@ -0,0 +0,0 @@ tasks.shadowJar { - transform(ModifiedLog4j2PluginsCacheFileTransformer::class.java) + } } +// Paper start - include reobf mappings in jar for stacktrace deobfuscation diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index f3be25511f..bdb1fffc8d 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -32,10 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +0,0 @@ -+import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer -+import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer +import io.papermc.paperweight.util.* -+import shadow.org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor.PLUGIN_CACHE_FILE +import java.util.Locale + +plugins { @@ -112,6 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +} + +tasks.shadowJar { ++ configurations = listOf(project.configurations.vanillaServer.get()) + archiveClassifier.set("mojang-mapped") + + for (relocation in relocation.relocations.get()) { @@ -121,8 +119,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + } -+ mergeServiceFiles() -+ transform(ModifiedLog4j2PluginsCacheFileTransformer::class.java) +} + +tasks.test { @@ -134,6 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + block: JavaExec.() -> Unit +): TaskProvider = register(name) { + group = "paper" ++ mainClass.set("org.bukkit.craftbukkit.Main") + standardInput = System.`in` + workingDir = rootProject.layout.projectDirectory + .dir(providers.gradleProperty("paper.runWorkDir").forUseAtConfigurationTime().getOrElse("run")) @@ -164,26 +161,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + block(this) +} + ++val runtimeClasspathWithoutVanillaServer = configurations.runtimeClasspath.flatMap { it.elements } ++ .zip(configurations.vanillaServer.map { it.singleFile.absolutePath }) { runtime, vanilla -> ++ runtime.filterNot { it.asFile.absolutePath == vanilla } ++ } ++ +tasks.registerRunTask("runShadow") { + description = "Spin up a test server from the shadowJar archiveFile" + classpath(tasks.shadowJar.flatMap { it.archiveFile }) ++ classpath(runtimeClasspathWithoutVanillaServer) +} + +tasks.registerRunTask("runReobf") { + description = "Spin up a test server from the reobfJar output jar" + classpath(tasks.reobfJar.flatMap { it.outputJar }) ++ classpath(runtimeClasspathWithoutVanillaServer) +} + +tasks.registerRunTask("runDev") { -+ description = "Spin up a non-shaded non-remapped test server" -+ classpath = java.sourceSets.main.get().runtimeClasspath -+ mainClass.set("org.bukkit.craftbukkit.Main") -+} -+ -+class ModifiedLog4j2PluginsCacheFileTransformer : Transformer by Log4j2PluginsCacheFileTransformer() { -+ override fun canTransformResource(element: FileTreeElement): Boolean { -+ return PLUGIN_CACHE_FILE == element.name || element.name == "Log4j2Plugins.dat" -+ } ++ description = "Spin up a non-relocated Mojang-mapped test server" ++ classpath(sourceSets.main.map { it.runtimeClasspath }) +} diff --git a/pom.xml b/pom.xml deleted file mode 100644