Add Paper version back to manifest, add runShadow, runReobf, and runDev tasks for testing

This commit is contained in:
Jason Penilla 2021-06-11 18:10:12 -07:00
parent a22a0e56ef
commit 9188180d7a
No known key found for this signature in database
GPG Key ID: 0E75A301420E48F8
2 changed files with 43 additions and 6 deletions

View File

@ -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<JavaExec> =
+ register<JavaExec>(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"

View File

@ -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(