From 35aeb0ddeb46993d42d987a509546faea7bbe3c3 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 + .../server/0001-Setup-Gradle-project.patch | 29 +++++++++---------- .../server/0003-Build-system-changes.patch | 17 ++++------- ...oleAppender-for-console-improvements.patch | 4 +-- ...n-prefixes-using-Log4J-configuration.patch | 4 +-- ...r-to-keep-logging-IO-off-main-thread.patch | 4 +-- .../0305-Implement-Brigadier-Mojang-API.patch | 4 +-- ...ktraces-in-log-messages-crash-report.patch | 29 +++++++++---------- .../server/0418-Implement-Mob-Goal-API.patch | 4 +-- ...pport-for-hex-color-codes-in-console.patch | 12 -------- 10 files changed, 42 insertions(+), 66 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f67bc31eb..ab9ef4e8c 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/0001-Setup-Gradle-project.patch b/patches/server/0001-Setup-Gradle-project.patch index 3474cc080..b1d11690e 100644 --- a/patches/server/0001-Setup-Gradle-project.patch +++ b/patches/server/0001-Setup-Gradle-project.patch @@ -28,14 +28,11 @@ index 67fb370cad6924895a6b27052dbd5c1767e3f0c9..bb338269c9e3bef4c274157c490d8b8f +/.factorypath diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 -index 0000000000000000000000000000000000000000..a19e05379d81e6f0bb0a78bc734a1cfdd355dc74 +index 0000000000000000000000000000000000000000..9778c18a2822b00d48134583de87ea281623427d --- /dev/null +++ b/build.gradle.kts -@@ -0,0 +1,153 @@ -+import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer -+import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer +@@ -0,0 +1,150 @@ +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..a19e05379d81e6f0bb0a78bc734a1cfd +} + +tasks.shadowJar { ++ configurations = listOf(project.configurations.vanillaServer.get()) + archiveClassifier.set("mojang-mapped") + + for (relocation in relocation.relocations.get()) { @@ -121,8 +119,6 @@ index 0000000000000000000000000000000000000000..a19e05379d81e6f0bb0a78bc734a1cfd + } + } + } -+ mergeServiceFiles() -+ transform(ModifiedLog4j2PluginsCacheFileTransformer::class.java) +} + +tasks.test { @@ -134,6 +130,7 @@ index 0000000000000000000000000000000000000000..a19e05379d81e6f0bb0a78bc734a1cfd + 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..a19e05379d81e6f0bb0a78bc734a1cfd + 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 diff --git a/patches/server/0003-Build-system-changes.patch b/patches/server/0003-Build-system-changes.patch index 62ff5824b..22b0bc619 100644 --- a/patches/server/0003-Build-system-changes.patch +++ b/patches/server/0003-Build-system-changes.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Build system changes diff --git a/build.gradle.kts b/build.gradle.kts -index 273746fe476a9a09ebca01c6ecd814b70fe1b4c2..6cab6b2f348366e7e0357638ac11df5961a7388d 100644 +index 9778c18a2822b00d48134583de87ea281623427d..19d4a798427de2c78b62a92246d47607a050a11d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -17,10 +17,9 @@ repositories { +@@ -14,10 +14,9 @@ repositories { dependencies { implementation(project(":Paper-API")) implementation("jline:jline:2.12.1") @@ -21,24 +21,17 @@ index 273746fe476a9a09ebca01c6ecd814b70fe1b4c2..6cab6b2f348366e7e0357638ac11df59 implementation("com.googlecode.json-simple:json-simple:1.1.1") { // This includes junit transitively for whatever reason isTransitive = false -@@ -52,6 +51,7 @@ 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) -@@ -77,9 +77,17 @@ relocation { +@@ -74,10 +73,18 @@ relocation { } } +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/0136-Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/0136-Use-TerminalConsoleAppender-for-console-improvements.patch index 2c4515abd..7e25157a7 100644 --- a/patches/server/0136-Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/0136-Use-TerminalConsoleAppender-for-console-improvements.patch @@ -19,10 +19,10 @@ Other changes: configuration diff --git a/build.gradle.kts b/build.gradle.kts -index 6cab6b2f348366e7e0357638ac11df5961a7388d..ff067710300454ed284d38a75cd6b3e5f04cf794 100644 +index 19d4a798427de2c78b62a92246d47607a050a11d..c8f39fae4527c4ff3256c687f3defbff7f87a68c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -16,7 +16,17 @@ repositories { +@@ -13,7 +13,17 @@ repositories { dependencies { implementation(project(":Paper-API")) diff --git a/patches/server/0156-Handle-plugin-prefixes-using-Log4J-configuration.patch b/patches/server/0156-Handle-plugin-prefixes-using-Log4J-configuration.patch index 78e3f21ca..1acb6fee9 100644 --- a/patches/server/0156-Handle-plugin-prefixes-using-Log4J-configuration.patch +++ b/patches/server/0156-Handle-plugin-prefixes-using-Log4J-configuration.patch @@ -15,10 +15,10 @@ This may cause additional prefixes to be disabled for plugins bypassing the plugin logger. diff --git a/build.gradle.kts b/build.gradle.kts -index ff067710300454ed284d38a75cd6b3e5f04cf794..ef5af1965d54e9ba9ff84d4f22ae77e4ccfa461c 100644 +index c8f39fae4527c4ff3256c687f3defbff7f87a68c..1c14144551f07cc61b6dbb2b70498b399442cebd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -25,7 +25,7 @@ dependencies { +@@ -22,7 +22,7 @@ dependencies { all its classes to check if they are plugins. Scanning takes about 1-2 seconds so adding this speeds up the server start. */ diff --git a/patches/server/0222-Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch b/patches/server/0222-Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch index 67107b1a8..aac6872e3 100644 --- a/patches/server/0222-Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch +++ b/patches/server/0222-Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use AsyncAppender to keep logging IO off main thread diff --git a/build.gradle.kts b/build.gradle.kts -index ef5af1965d54e9ba9ff84d4f22ae77e4ccfa461c..80849d9b582916be238ba8c8e79de5832eff3c9a 100644 +index 1c14144551f07cc61b6dbb2b70498b399442cebd..a2cef2a6f04ba58ba49ac08c9e22cf8003216c39 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -36,6 +36,7 @@ dependencies { +@@ -33,6 +33,7 @@ dependencies { } runtimeOnly("org.xerial:sqlite-jdbc:3.36.0.3") runtimeOnly("mysql:mysql-connector-java:8.0.27") diff --git a/patches/server/0305-Implement-Brigadier-Mojang-API.patch b/patches/server/0305-Implement-Brigadier-Mojang-API.patch index 291a6195f..81ff1dc96 100644 --- a/patches/server/0305-Implement-Brigadier-Mojang-API.patch +++ b/patches/server/0305-Implement-Brigadier-Mojang-API.patch @@ -10,10 +10,10 @@ Adds CommandRegisteredEvent - Allows manipulating the CommandNode to add more children/metadata for the client diff --git a/build.gradle.kts b/build.gradle.kts -index 7fc074f63d1c3b3cf09bb5f95fd7bc5c0968a5de..44f5a30a16f3d5604cd99bb39c8d744bb607d923 100644 +index a2cef2a6f04ba58ba49ac08c9e22cf8003216c39..caf8a5d3797883b4dad64a9da6b566c92cf1c506 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -16,6 +16,7 @@ repositories { +@@ -13,6 +13,7 @@ repositories { dependencies { implementation(project(":Paper-API")) diff --git a/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 185bb4d3b..199078611 100644 --- a/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -6,20 +6,17 @@ Subject: [PATCH] Deobfuscate stacktraces in log messages, crash reports, and diff --git a/build.gradle.kts b/build.gradle.kts -index 44f5a30a16f3d5604cd99bb39c8d744bb607d923..8f65d5d3a5fa58394b0e398bed80044aec3fcc7c 100644 +index caf8a5d3797883b4dad64a9da6b566c92cf1c506..99ab6194dbcea67875c6cdf3f29bb41fff4a39b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -1,7 +1,9 @@ - import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer - import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer +@@ -1,4 +1,6 @@ +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 plugins { -@@ -12,6 +14,11 @@ plugins { +@@ -9,6 +11,11 @@ plugins { repositories { maven("https://libraries.minecraft.net/") @@ -31,7 +28,15 @@ index 44f5a30a16f3d5604cd99bb39c8d744bb607d923..8f65d5d3a5fa58394b0e398bed80044a } dependencies { -@@ -43,6 +50,8 @@ dependencies { +@@ -24,6 +31,7 @@ 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") +@@ -40,6 +48,8 @@ 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 44f5a30a16f3d5604cd99bb39c8d744bb607d923..8f65d5d3a5fa58394b0e398bed80044a testImplementation("junit:junit:4.13.1") testImplementation("org.hamcrest:hamcrest-library:1.3") } -@@ -87,6 +96,7 @@ relocation { - relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$packageVersion") { - exclude("org.bukkit.craftbukkit.Main*") +@@ -106,6 +116,45 @@ tasks.shadowJar { } -+ relocate("net.fabricmc.mapping-io" to "io.papermc.dependency.mappingio") // Paper - } - - val generatePom = tasks.named("generatePomFileForMavenPublication") -@@ -111,6 +121,45 @@ tasks.shadowJar { - transform(ModifiedLog4j2PluginsCacheFileTransformer::class.java) } +// Paper start - include reobf mappings in jar for stacktrace deobfuscation diff --git a/patches/server/0418-Implement-Mob-Goal-API.patch b/patches/server/0418-Implement-Mob-Goal-API.patch index d2822a775..e8e5781e3 100644 --- a/patches/server/0418-Implement-Mob-Goal-API.patch +++ b/patches/server/0418-Implement-Mob-Goal-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Implement Mob Goal API diff --git a/build.gradle.kts b/build.gradle.kts -index 8f65d5d3a5fa58394b0e398bed80044aec3fcc7c..eaeed610e3f1a622b2ece220d595fbca9c750d20 100644 +index 99ab6194dbcea67875c6cdf3f29bb41fff4a39b9..4bf4127bb8845499a1a629e03b0c767f0eb43461 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -52,6 +52,7 @@ dependencies { +@@ -50,6 +50,7 @@ dependencies { implementation("net.fabricmc:mapping-io:0.3.0") // Paper - needed to read mappings for stacktrace deobfuscation diff --git a/patches/server/0595-Add-support-for-hex-color-codes-in-console.patch b/patches/server/0595-Add-support-for-hex-color-codes-in-console.patch index cc13dcf88..4d129a981 100644 --- a/patches/server/0595-Add-support-for-hex-color-codes-in-console.patch +++ b/patches/server/0595-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 eaeed610e3f1a622b2ece220d595fbca9c750d20..5e1b87f84ab78952291c16ef468b83c9c5f21112 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -34,6 +34,7 @@ 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..a4315961b7a465fb4872a4d67e7c26d4b4ed1fb9