From 9188180d7a8b5cd16734a2352faca52ef9532580 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 11 Jun 2021 18:10:12 -0700 Subject: [PATCH] Add Paper version back to manifest, add `runShadow`, `runReobf`, and `runDev` tasks for testing --- .../server/0001-Setup-Gradle-project.patch | 41 ++++++++++++++++++- .../server/0003-Build-system-changes.patch | 8 ++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/patches/server/0001-Setup-Gradle-project.patch b/patches/server/0001-Setup-Gradle-project.patch index e69ca18a1..cd9ca8645 100644 --- a/patches/server/0001-Setup-Gradle-project.patch +++ b/patches/server/0001-Setup-Gradle-project.patch @@ -17,13 +17,15 @@ index 67fb370cad6924895a6b27052dbd5c1767e3f0c9..3e05459f27c4c5697ae65da504d67a6a /.project diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 -index 0000000000000000000000000000000000000000..b038528ba5ab9790a6bdb1c51ff072f9b8a64bf8 +index 0000000000000000000000000000000000000000..ccb67fe90e25010f7c8ca168d60d096ef95c4429 --- /dev/null +++ b/build.gradle.kts -@@ -0,0 +1,84 @@ +@@ -0,0 +1,121 @@ +import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer +import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer +import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer ++import io.papermc.paperweight.util.Git ++import io.papermc.paperweight.util.path +import org.gradle.api.file.FileTreeElement +import shadow.org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor.PLUGIN_CACHE_FILE +import java.util.Date @@ -64,9 +66,13 @@ index 0000000000000000000000000000000000000000..b038528ba5ab9790a6bdb1c51ff072f9 + +tasks.jar { + manifest { ++ val git = Git(rootProject.layout.projectDirectory.path) ++ val gitHashCmd = git("rev-parse", "HEAD") ++ val gitHash = gitHashCmd.getText().substring(0, 7) + attributes(mapOf( + "Main-Class" to "org.bukkit.craftbukkit.Main", + "Implementation-Title" to "CraftBukkit", ++ "Implementation-Version" to "git-Paper-\"$gitHash\"", + "Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper + "Specification-Title" to "Bukkit", + "Specification-Version" to project.version, @@ -100,6 +106,37 @@ index 0000000000000000000000000000000000000000..b038528ba5ab9790a6bdb1c51ff072f9 + exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") +} + ++fun TaskContainer.registerRunTask(name: String, block: JavaExec.() -> Unit): TaskProvider = ++ register(name) { ++ group = "Paper" ++ workingDir = rootProject.projectDir.resolve("run") ++ doFirst { ++ if (!workingDir.exists()) workingDir.mkdir() ++ } ++ standardInput = System.`in` ++ args("--nogui") ++ systemProperty("net.kyori.adventure.text.warnWhenLegacyFormattingDetected", true) ++ block(this) ++ } ++ ++tasks.registerRunTask("runShadow") { ++ description = "Spin up a test server from the shadowJar archiveFile" ++ classpath(tasks.shadowJar.flatMap { it.archiveFile }) ++} ++ ++tasks.registerRunTask("runReobf") { ++ description = "Spin up a test server from the reobfJar output jar" ++ classpath(tasks.reobfJar.flatMap { it.outputJar }) ++} ++ ++tasks.registerRunTask("runDev") { ++ description = "Spin up a non-shaded non-remapped test server" ++ classpath = project.convention.getPlugin(JavaPluginConvention::class.java) ++ .sourceSets.getByName("main").runtimeClasspath ++ main = "org.bukkit.craftbukkit.Main" ++ systemProperty("disable.watchdog", true) ++} ++ +class ModifiedLog4j2PluginsCacheFileTransformer : Transformer by Log4j2PluginsCacheFileTransformer() { + override fun canTransformResource(element: FileTreeElement): Boolean { + return PLUGIN_CACHE_FILE == element.name || element.name == "Log4j2Plugins.dat" diff --git a/patches/server/0003-Build-system-changes.patch b/patches/server/0003-Build-system-changes.patch index 3c91de463..29cd18e97 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 b038528ba5ab9790a6bdb1c51ff072f9b8a64bf8..25fa56d26bd88e4647b4c25ad6783ff90a05b2c4 100644 +index ccb67fe90e25010f7c8ca168d60d096ef95c4429..f353524ada2caa05824b1e7ded17a1c00473d906 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -20,21 +20,24 @@ repositories { +@@ -22,21 +22,24 @@ repositories { dependencies { implementation(project(":Paper-API")) implementation("jline:jline:2.12.1") @@ -37,7 +37,7 @@ index b038528ba5ab9790a6bdb1c51ff072f9b8a64bf8..25fa56d26bd88e4647b4c25ad6783ff9 testImplementation("junit:junit:4.13.1") testImplementation("org.hamcrest:hamcrest-library:1.3") } -@@ -47,7 +50,8 @@ tasks.jar { +@@ -53,7 +56,8 @@ tasks.jar { "Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, @@ -47,7 +47,7 @@ index b038528ba5ab9790a6bdb1c51ff072f9b8a64bf8..25fa56d26bd88e4647b4c25ad6783ff9 )) for (tld in listOf("net", "com", "org")) { attributes(mapOf( -@@ -59,7 +63,7 @@ tasks.jar { +@@ -65,7 +69,7 @@ tasks.jar { tasks.shadowJar { listOf(