diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index 2e6121d65d..dee958478d 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -24,6 +24,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +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..00000000000000000000000000000000 + +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..00000000000000000000000000000000 + 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"