2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Kyle Wood <demonwav@gmail.com>
|
|
|
|
Date: Thu, 10 Dec 2020 20:54:19 -0800
|
|
|
|
Subject: [PATCH] Setup Gradle project
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/.gitignore b/.gitignore
|
|
|
|
index 67fb370cad6924895a6b27052dbd5c1767e3f0c9..3e05459f27c4c5697ae65da504d67a6a2f617b57 100644
|
|
|
|
--- a/.gitignore
|
|
|
|
+++ b/.gitignore
|
|
|
|
@@ -1,3 +1,6 @@
|
|
|
|
+.gradle/
|
|
|
|
+build/
|
|
|
|
+
|
|
|
|
# Eclipse stuff
|
|
|
|
/.classpath
|
|
|
|
/.project
|
|
|
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
|
|
new file mode 100644
|
2021-06-17 01:23:02 +02:00
|
|
|
index 0000000000000000000000000000000000000000..84af6353d060c65d5f125559becc011aeba8a842
|
2021-06-11 14:02:28 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/build.gradle.kts
|
2021-06-17 01:23:02 +02:00
|
|
|
@@ -0,0 +1,134 @@
|
2021-06-12 02:22:53 +02:00
|
|
|
+import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer
|
|
|
|
+import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
|
2021-06-12 03:10:12 +02:00
|
|
|
+import io.papermc.paperweight.util.Git
|
|
|
|
+import io.papermc.paperweight.util.path
|
2021-06-12 02:22:53 +02:00
|
|
|
+import shadow.org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor.PLUGIN_CACHE_FILE
|
|
|
|
+import java.text.SimpleDateFormat
|
2021-06-16 07:10:05 +02:00
|
|
|
+import java.util.Date
|
2021-06-17 01:23:02 +02:00
|
|
|
+import java.util.Locale
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+plugins {
|
|
|
|
+ java
|
2021-06-15 03:50:13 +02:00
|
|
|
+ `maven-publish`
|
2021-06-11 14:02:28 +02:00
|
|
|
+ id("com.github.johnrengelman.shadow")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+val packageVersion = providers.gradleProperty("packageVersion").forUseAtConfigurationTime().get()
|
|
|
|
+
|
|
|
|
+repositories {
|
|
|
|
+ maven("https://libraries.minecraft.net/")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+dependencies {
|
|
|
|
+ implementation(project(":Paper-API"))
|
|
|
|
+ implementation("jline:jline:2.12.1")
|
|
|
|
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") {
|
|
|
|
+ exclude(group = "org.apache.logging.log4j", module = "log4j-api")
|
|
|
|
+ }
|
|
|
|
+ implementation("org.ow2.asm:asm:9.1")
|
|
|
|
+ implementation("com.googlecode.json-simple:json-simple:1.1.1") {
|
|
|
|
+ // This includes junit transitively for whatever reason
|
|
|
|
+ isTransitive = false
|
|
|
|
+ }
|
|
|
|
+ runtimeOnly("org.xerial:sqlite-jdbc:3.34.0")
|
|
|
|
+ runtimeOnly("mysql:mysql-connector-java:5.1.49")
|
|
|
|
+
|
|
|
|
+ runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.1")
|
|
|
|
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0")
|
|
|
|
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.0")
|
|
|
|
+
|
|
|
|
+ testImplementation("junit:junit:4.13.1")
|
|
|
|
+ testImplementation("org.hamcrest:hamcrest-library:1.3")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+tasks.jar {
|
2021-06-17 01:23:02 +02:00
|
|
|
+ archiveClassifier.set("dev")
|
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
+ manifest {
|
2021-06-12 03:10:12 +02:00
|
|
|
+ val git = Git(rootProject.layout.projectDirectory.path)
|
2021-06-17 01:23:02 +02:00
|
|
|
+ val gitHash = git("rev-parse", "HEAD").getText().substring(0, 7)
|
|
|
|
+ attributes(
|
2021-06-11 14:02:28 +02:00
|
|
|
+ "Main-Class" to "org.bukkit.craftbukkit.Main",
|
|
|
|
+ "Implementation-Title" to "CraftBukkit",
|
2021-06-12 03:10:12 +02:00
|
|
|
+ "Implementation-Version" to "git-Paper-\"$gitHash\"",
|
2021-06-12 02:22:53 +02:00
|
|
|
+ "Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
+ "Specification-Title" to "Bukkit",
|
|
|
|
+ "Specification-Version" to project.version,
|
2021-06-17 01:23:02 +02:00
|
|
|
+ "Specification-Vendor" to "Bukkit Team",
|
|
|
|
+ )
|
|
|
|
+ for (tld in setOf("net", "com", "org")) {
|
|
|
|
+ attributes("$tld/bukkit", "Sealed" to true)
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2021-06-17 01:23:02 +02:00
|
|
|
+publishing {
|
2021-06-15 03:50:13 +02:00
|
|
|
+ publications.create<MavenPublication>("maven") {
|
2021-06-17 01:23:02 +02:00
|
|
|
+ artifactId = rootProject.name.toLowerCase(Locale.ENGLISH)
|
2021-06-15 03:50:13 +02:00
|
|
|
+ artifact(tasks.reobfJar) {
|
2021-06-17 01:23:02 +02:00
|
|
|
+ classifier = null
|
2021-06-15 03:50:13 +02:00
|
|
|
+ }
|
2021-06-17 01:23:02 +02:00
|
|
|
+ artifact(tasks.shadowJar)
|
2021-06-15 03:50:13 +02:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
+tasks.shadowJar {
|
2021-06-17 01:23:02 +02:00
|
|
|
+ archiveClassifier.set("mojang-mapped")
|
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
+ listOf(
|
|
|
|
+ "jline", "it.unimi", "org.apache.commons.codec", "org.apache.commons.io",
|
|
|
|
+ "org.apache.commons.lang3", "org.objectweb.asm"
|
|
|
|
+ ).forEach { pack ->
|
|
|
|
+ relocate(pack, "org.bukkit.craftbukkit.libs.$pack")
|
|
|
|
+ }
|
|
|
|
+ relocate("org.bukkit.craftbukkit", "org.bukkit.craftbukkit.v$packageVersion") {
|
|
|
|
+ exclude("org.bukkit.craftbukkit.Main*")
|
|
|
|
+ }
|
2021-06-13 04:23:21 +02:00
|
|
|
+ mergeServiceFiles()
|
2021-06-12 02:22:53 +02:00
|
|
|
+ transform(ModifiedLog4j2PluginsCacheFileTransformer::class.java)
|
2021-06-11 14:02:28 +02:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+tasks.test {
|
|
|
|
+ exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class")
|
|
|
|
+}
|
2021-06-12 02:22:53 +02:00
|
|
|
+
|
2021-06-16 07:10:05 +02:00
|
|
|
+fun TaskContainer.registerRunTask(
|
|
|
|
+ name: String, block: JavaExec.() -> Unit
|
|
|
|
+): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
|
|
|
+ group = "paper"
|
|
|
|
+ standardInput = System.`in`
|
|
|
|
+ workingDir = rootProject.layout.projectDirectory.dir(
|
|
|
|
+ providers.gradleProperty("runWorkDir").forUseAtConfigurationTime().orElse("run")
|
|
|
|
+ ).get().asFile
|
|
|
|
+ args("--nogui")
|
|
|
|
+ systemProperty("net.kyori.adventure.text.warnWhenLegacyFormattingDetected", true)
|
|
|
|
+ if (project.hasProperty("disableWatchdog")) {
|
|
|
|
+ systemProperty("disable.watchdog", true)
|
2021-06-12 03:10:12 +02:00
|
|
|
+ }
|
2021-06-16 07:10:05 +02:00
|
|
|
+ doFirst {
|
|
|
|
+ workingDir.mkdirs()
|
|
|
|
+ }
|
|
|
|
+ block(this)
|
|
|
|
+}
|
2021-06-12 03:10:12 +02:00
|
|
|
+
|
|
|
|
+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"
|
2021-06-16 07:10:05 +02:00
|
|
|
+ classpath = java.sourceSets.main.get().runtimeClasspath
|
|
|
|
+ mainClass.set("org.bukkit.craftbukkit.Main")
|
2021-06-12 03:10:12 +02:00
|
|
|
+}
|
|
|
|
+
|
2021-06-12 02:22:53 +02:00
|
|
|
+class ModifiedLog4j2PluginsCacheFileTransformer : Transformer by Log4j2PluginsCacheFileTransformer() {
|
|
|
|
+ override fun canTransformResource(element: FileTreeElement): Boolean {
|
|
|
|
+ return PLUGIN_CACHE_FILE == element.name || element.name == "Log4j2Plugins.dat"
|
|
|
|
+ }
|
|
|
|
+}
|