From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Thu, 10 Dec 2020 20:54:19 -0800 Subject: [PATCH] Setup Gradle project The pom.xml file is deleted in this patch so the patch will fail to apply if there are changes made to it from upstream - thus notifying us that changes were made. diff --git a/.gitignore b/.gitignore index 37dab9e868dbfb019c271a547d975a48ad1cb571..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.gradle/ +build/ + # Eclipse stuff /.classpath /.project @@ -39,3 +42,7 @@ dependency-reduced-pom.xml /src/main/resources/achievement /src/main/resources/lang + +# vs code +/.vscode +/.factorypath diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..36e6426438865213d2e5e11ee3b1d6e538d475f7 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,131 @@ +import io.papermc.paperweight.util.* + +plugins { + java + `maven-publish` +} + +dependencies { + implementation(project(":paper-api")) + implementation("jline:jline:2.12.1") + implementation("org.apache.logging.log4j:log4j-iostreams:2.24.1") { + exclude(group = "org.apache.logging.log4j", module = "log4j-api") + } + implementation("org.ow2.asm:asm-commons:9.7.1") + implementation("commons-lang:commons-lang:2.6") + runtimeOnly("org.xerial:sqlite-jdbc:3.47.0.0") + runtimeOnly("com.mysql:mysql-connector-j:9.1.0") + + runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6") + runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18") + runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18") + + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0") + testImplementation("org.hamcrest:hamcrest:2.2") + testImplementation("org.mockito:mockito-core:5.14.1") + testImplementation("org.ow2.asm:asm-tree:9.7.1") +} + +paperweight { + craftBukkitPackageVersion.set("v1_21_R3") // also needs to be updated in MappingEnvironment +} + +tasks.jar { + archiveClassifier.set("dev") + + manifest { + val git = Git(rootProject.layout.projectDirectory.path) + val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() + val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" + val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper + attributes( + "Main-Class" to "org.bukkit.craftbukkit.Main", + "Implementation-Title" to "CraftBukkit", + "Implementation-Version" to "git-Paper-$implementationVersion", + "Implementation-Vendor" to date, // Paper + "Specification-Title" to "Bukkit", + "Specification-Version" to project.version, + "Specification-Vendor" to "Bukkit Team", + ) + for (tld in setOf("net", "com", "org")) { + attributes("$tld/bukkit", "Sealed" to true) + } + } +} + +publishing { + publications.create("maven") { + } +} + +tasks.test { + include("**/**TestSuite.class") + workingDir = temporaryDir + useJUnitPlatform { + forkEvery = 1 + excludeTags("Slow") + } +} + +fun TaskContainer.registerRunTask( + name: String, + 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").getOrElse("run")) + .asFile + javaLauncher.set(project.javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(21)) + vendor.set(JvmVendorSpec.JETBRAINS) + }) + jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:+AllowRedefinitionToAddDeleteMethods") + + if (rootProject.childProjects["test-plugin"] != null) { + val testPluginJar = rootProject.project(":test-plugin").tasks.jar.flatMap { it.archiveFile } + inputs.file(testPluginJar) + args("-add-plugin=${testPluginJar.get().asFile.absolutePath}") + } + + args("--nogui") + systemProperty("net.kyori.adventure.text.warnWhenLegacyFormattingDetected", true) + if (providers.gradleProperty("paper.runDisableWatchdog").getOrElse("false") == "true") { + systemProperty("disable.watchdog", true) + } + systemProperty("io.papermc.paper.suppress.sout.nags", true) + + val memoryGb = providers.gradleProperty("paper.runMemoryGb").getOrElse("2") + minHeapSize = "${memoryGb}G" + maxHeapSize = "${memoryGb}G" + + doFirst { + workingDir.mkdirs() + } + + 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("runServerJar") { + description = "Spin up a test server from the serverJar archiveFile" + classpath(tasks.serverJar.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-relocated Mojang-mapped test server" + classpath(sourceSets.main.map { it.runtimeClasspath }) +} diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 8fdbc360f03b7ad561be4497f0793e81aa2e170b..0000000000000000000000000000000000000000 --- a/pom.xml +++ /dev/null @@ -1,691 +0,0 @@ - - 4.0.0 - org.spigotmc - spigot - jar - 1.21.4-R0.1-SNAPSHOT - Spigot - https://www.spigotmc.org/ - - - org.spigotmc - spigot-parent - dev-SNAPSHOT - ../pom.xml - - - - true - AllFeatures,Bundle,Legacy,Normal,VanillaFeature - UTF-8 - unknown - git - 1_21_R3 - 21 - - - - - minecraft-libraries - Minecraft Libraries - https://libraries.minecraft.net/ - - - - - - org.spigotmc - spigot-api - ${project.version} - compile - - - org.spigotmc - minecraft-server - ${project.version} - compile - - - jline - jline - 2.12.1 - compile - - - org.apache.logging.log4j - log4j-iostreams - 2.24.1 - compile - - - org.ow2.asm - asm-commons - 9.7.1 - compile - - - - com.fasterxml.jackson.core - jackson-annotations - 2.13.4 - compile - - - com.fasterxml.jackson.core - jackson-core - 2.13.4 - compile - - - com.fasterxml.jackson.core - jackson-databind - 2.13.4.2 - compile - - - com.github.oshi - oshi-core - 6.6.5 - compile - - - com.github.stephenc.jcip - jcip-annotations - 1.0-1 - compile - - - com.microsoft.azure - msal4j - 1.17.2 - compile - - - com.mojang - authlib - 6.0.57 - compile - - - com.mojang - brigadier - 1.3.10 - compile - - - com.mojang - datafixerupper - 8.0.16 - compile - - - com.mojang - jtracy - 1.0.29 - compile - - - com.mojang - logging - 1.5.10 - compile - - - com.nimbusds - content-type - 2.3 - compile - - - com.nimbusds - lang-tag - 1.7 - compile - - - com.nimbusds - nimbus-jose-jwt - 9.40 - compile - - - com.nimbusds - oauth2-oidc-sdk - 11.18 - compile - - - commons-io - commons-io - 2.17.0 - compile - - - io.netty - netty-buffer - 4.1.115.Final - compile - - - io.netty - netty-codec - 4.1.115.Final - compile - - - io.netty - netty-common - 4.1.115.Final - compile - - - io.netty - netty-handler - 4.1.115.Final - compile - - - io.netty - netty-resolver - 4.1.115.Final - compile - - - io.netty - netty-transport - 4.1.115.Final - compile - - - io.netty - netty-transport-classes-epoll - 4.1.115.Final - compile - - - io.netty - netty-transport-native-epoll - 4.1.115.Final - linux-x86_64 - compile - - - io.netty - netty-transport-native-epoll - 4.1.115.Final - linux-aarch_64 - compile - - - io.netty - netty-transport-native-unix-common - 4.1.115.Final - compile - - - it.unimi.dsi - fastutil - 8.5.15 - compile - - - net.java.dev.jna - jna - 5.15.0 - compile - - - net.java.dev.jna - jna-platform - 5.15.0 - compile - - - net.minidev - accessors-smart - 2.5.1 - compile - - - net.minidev - json-smart - 2.5.1 - compile - - - net.sf.jopt-simple - jopt-simple - 5.0.4 - compile - - - org.apache.commons - commons-lang3 - 3.17.0 - compile - - - org.apache.logging.log4j - log4j-api - 2.24.1 - compile - - - org.apache.logging.log4j - log4j-core - 2.24.1 - compile - - - org.apache.logging.log4j - log4j-slf4j2-impl - 2.24.1 - compile - - - org.lz4 - lz4-java - 1.8.0 - compile - - - org.slf4j - slf4j-api - 2.0.16 - compile - - - - - commons-lang - commons-lang - 2.6 - compile - - - - com.googlecode.json-simple - json-simple - 1.1.1 - runtime - - - junit - junit - - - - - org.xerial - sqlite-jdbc - 3.47.0.0 - runtime - - - com.mysql - mysql-connector-j - 9.1.0 - runtime - - - - org.apache.maven - maven-resolver-provider - 3.9.6 - runtime - - - org.apache.maven.resolver - maven-resolver-connector-basic - 1.9.18 - runtime - - - org.apache.maven.resolver - maven-resolver-transport-http - 1.9.18 - runtime - - - - org.jetbrains - annotations-java5 - 24.1.0 - provided - - - - org.junit.jupiter - junit-jupiter - 5.10.2 - test - - - org.junit.platform - junit-platform-suite-engine - 1.10.0 - test - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-core - 5.14.1 - test - - - org.ow2.asm - asm-tree - 9.7.1 - test - - - - - - - - net.md-5 - scriptus - 0.5.0 - - - ex-spigot - - ${bt.name}-Spigot-%s - ../ - spigot.desc - - initialize - - describe - - - - ex-craftbukkit - - -%s - ../../CraftBukkit - craftbukkit.desc - - initialize - - describe - - - - - - org.apache.maven.plugins - maven-clean-plugin - 3.2.0 - - - initialize - - clean - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.4.1 - - - - false - - - org.bukkit.craftbukkit.Main - CraftBukkit - ${spigot.desc}${craftbukkit.desc} - ${project.build.outputTimestamp} - Bukkit - ${api.version} - Bukkit Team - true - - - - net/bukkit/ - - true - - - - com/bukkit/ - - true - - - - org/bukkit/ - - true - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.3 - - - package - - shade - - - ${shadeSourcesJar} - - - org.spigotmc:minecraft-server - - - - - org.bukkit.craftbukkit - org.bukkit.craftbukkit.v${minecraft_version} - - org.bukkit.craftbukkit.bootstrap.* - org.bukkit.craftbukkit.Main* - - - - - - - - - net.md-5 - specialsource-maven-plugin - 2.0.3 - - - package - - remap - - remap-members - - false - ${project.build.directory}/server.txt - org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot-members - true - - - - - - net.nicoulaj.maven.plugins - checksum-maven-plugin - 1.11 - - - package - - artifacts - dependencies - - - - SHA-256 - - true - - compile - runtime - - true - true - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.7.1 - - - package - - single - - - - - false - - - org.bukkit.craftbukkit.bootstrap.Main - - - false - - ${project.basedir}/src/assembly/bootstrap.xml - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - - false - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.2.5 - - ${basedir}/target/test-server - false - - **/*TestSuite.java - - - - - - - - - shadeSourcesJar - - true - true - - - - development - - false - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.3.1 - - - test-compile - - check - - - - - checkstyle.xml - true - - - - com.puppycrawl.tools - checkstyle - 8.45.1 - - - - - - - - remapped - - - - net.md-5 - specialsource-maven-plugin - - - verify - - remap - - remap-obf - - false - org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot - true - true - remapped-obf - - - - verify - - remap - - remap-mojang - - false - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:${project.version}:txt:maps-mojang - true - remapped-mojang - - - - - - - - -