From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Sun, 26 May 2024 23:18:01 +0900 Subject: [PATCH] Cleanup buildscripts diff --git a/build.gradle.kts b/build.gradle.kts index acca28dd3e99821e4f55794946ed27b7e8c780a5..b95eda82341edf50f74da6760b42c47a7365e320 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -43,85 +43,126 @@ paperweight { craftBukkitPackageVersion.set("v1_20_R4") // also needs to be updated in MappingEnvironment } -// Pufferfish Start -tasks.withType { - val compilerArgs = options.compilerArgs - compilerArgs.add("--add-modules=jdk.incubator.vector") -} -// Pufferfish End - -tasks.jar { - archiveClassifier.set("dev") - - manifest { - val git = Git(rootProject.layout.projectDirectory.path) - val mcVersion = rootProject.providers.gradleProperty("mcVersion").get() - val build = System.getenv("BUILD_NUMBER") ?: null - val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() - val implementationVersion = "git-Pufferfish-$gitHash" // Pufferfish - val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper - val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper - attributes( - "Main-Class" to "org.bukkit.craftbukkit.Main", - "Implementation-Title" to rootProject.providers.gradleProperty("brandName").get(), // Purpur // Plazma - Rebrand // Plazma - Fork-friendly Rebranding - "Implementation-Version" to implementationVersion, - "Implementation-Vendor" to date, // Paper - "Specification-Title" to rootProject.providers.gradleProperty("brandName").get(), // Purpur // Plazma - Fork-friendly Rebranding - "Specification-Version" to project.version, - "Specification-Vendor" to rootProject.providers.gradleProperty("providerName").get(), // Purpur // Plazma - Fork-friendly Rebranding - "Brand-Id" to rootProject.providers.gradleProperty("brandKey").get(), // Purpur // Plazma - Fork-friendly Rebranding - "Brand-Name" to rootProject.providers.gradleProperty("brandName").get(), // Purpur // Plazma - Fork-friendly Rebranding - "Build-Number" to (build ?: ""), - "Build-Time" to Instant.now().toString(), - "Git-Branch" to gitBranch, // Paper - "Git-Commit" to gitHash, // Paper - "CraftBukkit-Package-Version" to paperweight.craftBukkitPackageVersion.get(), // Paper - ) - for (tld in setOf("net", "com", "org")) { - attributes("$tld/bukkit", "Sealed" to true) +// Plazma start - Cleanup buildscripts +tasks { + // Pufferfish Start + withType { + val compilerArgs = options.compilerArgs + compilerArgs.add("--add-modules=jdk.incubator.vector") + } + // Pufferfish End + + jar { + archiveClassifier.set("dev") + + manifest { + val git = Git(rootProject.layout.projectDirectory.path) + val mcVersion = rootProject.providers.gradleProperty("mcVersion").get() + val build = System.getenv("BUILD_NUMBER") ?: null + val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() + val implementationVersion = "git-Pufferfish-$gitHash" // Pufferfish + val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper + val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper + attributes( + "Main-Class" to "org.bukkit.craftbukkit.Main", + "Implementation-Title" to rootProject.providers.gradleProperty("brandName").get(), // Purpur // Plazma - Rebrand // Plazma - Fork-friendly Rebranding + "Implementation-Version" to implementationVersion, + "Implementation-Vendor" to date, // Paper + "Specification-Title" to rootProject.providers.gradleProperty("brandName").get(), // Purpur // Plazma - Fork-friendly Rebranding + "Specification-Version" to project.version, + "Specification-Vendor" to rootProject.providers.gradleProperty("providerName").get(), // Purpur // Plazma - Fork-friendly Rebranding + "Brand-Id" to rootProject.providers.gradleProperty("brandKey").get(), // Purpur // Plazma - Fork-friendly Rebranding + "Brand-Name" to rootProject.providers.gradleProperty("brandName").get(), // Purpur // Plazma - Fork-friendly Rebranding + "Build-Number" to (build ?: ""), + "Build-Time" to Instant.now().toString(), + "Git-Branch" to gitBranch, // Paper + "Git-Commit" to gitHash, // Paper + "CraftBukkit-Package-Version" to paperweight.craftBukkitPackageVersion.get(), // Paper + ) + for (tld in setOf("net", "com", "org")) { + attributes("$tld/bukkit", "Sealed" to true) + } } } -} - -// Paper start - compile tests with -parameters for better junit parameterized test names -tasks.compileTestJava { - options.compilerArgs.add("-parameters") -} -// Paper end -publishing { - publications.create("maven") { + // Paper start - compile tests with -parameters for better junit parameterized test names + compileTestJava { + options.compilerArgs.add("-parameters") } -} + // Paper end -// Paper start -val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { - badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;") - jarToScan.set(tasks.serverJar.flatMap { it.archiveFile }) - classpath.from(configurations.compileClasspath) -} -tasks.check { - dependsOn(scanJar) -} -// Paper end -// Paper start - use TCA for console improvements -tasks.serverJar { - from(alsoShade.elements.map { - it.map { f -> - if (f.asFile.isFile) { - zipTree(f.asFile) - } else { - f.asFile + // Paper start + val scanJar = register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { + badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;") + jarToScan.set(serverJar.flatMap { it.archiveFile }) + classpath.from(configurations.compileClasspath) + } + check { + dependsOn(scanJar) + } + // Paper end + + // Paper start - use TCA for console improvements + serverJar { + from(alsoShade.elements.map { + it.map { f -> + if (f.asFile.isFile) { + zipTree(f.asFile) + } else { + f.asFile + } } + }) + } + // Paper end - use TCA for console improvements + + test { + exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") + useJUnitPlatform() + } + + val runtimeClasspathWithoutVanillaServer = configurations.runtimeClasspath.flatMap { it.elements } + .zip(configurations.vanillaServer.map { it.singleFile.absolutePath }) { runtime, vanilla -> + runtime.filterNot { it.asFile.absolutePath == vanilla } } - }) -} -// Paper end - use TCA for console improvements -tasks.test { - exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") - useJUnitPlatform() + registerRunTask("runServer") { + description = "Spin up a test server from the Mojang mapped server jar" + classpath(includeMappings.flatMap { it.outputJar }) + classpath(runtimeClasspathWithoutVanillaServer) + } + registerRunTask("runReobfServer") { + description = "Spin up a test server from the reobfJar output jar" + classpath(reobfJar.flatMap { it.outputJar }) + classpath(runtimeClasspathWithoutVanillaServer) + } + registerRunTask("runDevServer") { + description = "Spin up a test server without assembling a jar" + classpath(sourceSets.main.map { it.runtimeClasspath }) + jvmArgs("-DPaper.pushPaperAssetsRoot=true") + } + registerRunTask("runBundler") { + description = "Spin up a test server from the Mojang mapped bundler jar" + classpath(rootProject.tasks.named("createMojmapBundlerJar").flatMap { it.outputZip }) + mainClass.set(null as String?) + } + registerRunTask("runReobfBundler") { + description = "Spin up a test server from the reobf bundler jar" + classpath(rootProject.tasks.named("createReobfBundlerJar").flatMap { it.outputZip }) + mainClass.set(null as String?) + } + registerRunTask("runPaperclip") { + description = "Spin up a test server from the Mojang mapped Paperclip jar" + classpath(rootProject.tasks.named("createMojmapPaperclipJar").flatMap { it.outputZip }) + mainClass.set(null as String?) + } + registerRunTask("runReobfPaperclip") { + description = "Spin up a test server from the reobf Paperclip jar" + classpath(rootProject.tasks.named("createReobfPaperclipJar").flatMap { it.outputZip }) + mainClass.set(null as String?) + } } +// Plazma end - Cleanup buildscripts fun TaskContainer.registerRunTask( name: String, @@ -162,47 +203,3 @@ fun TaskContainer.registerRunTask( 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("runServer") { - description = "Spin up a test server from the Mojang mapped server jar" - classpath(tasks.includeMappings.flatMap { it.outputJar }) - classpath(runtimeClasspathWithoutVanillaServer) -} - -tasks.registerRunTask("runReobfServer") { - description = "Spin up a test server from the reobfJar output jar" - classpath(tasks.reobfJar.flatMap { it.outputJar }) - classpath(runtimeClasspathWithoutVanillaServer) -} - -tasks.registerRunTask("runDevServer") { - description = "Spin up a test server without assembling a jar" - classpath(sourceSets.main.map { it.runtimeClasspath }) - jvmArgs("-DPaper.pushPaperAssetsRoot=true") -} - -tasks.registerRunTask("runBundler") { - description = "Spin up a test server from the Mojang mapped bundler jar" - classpath(rootProject.tasks.named("createMojmapBundlerJar").flatMap { it.outputZip }) - mainClass.set(null as String?) -} -tasks.registerRunTask("runReobfBundler") { - description = "Spin up a test server from the reobf bundler jar" - classpath(rootProject.tasks.named("createReobfBundlerJar").flatMap { it.outputZip }) - mainClass.set(null as String?) -} -tasks.registerRunTask("runPaperclip") { - description = "Spin up a test server from the Mojang mapped Paperclip jar" - classpath(rootProject.tasks.named("createMojmapPaperclipJar").flatMap { it.outputZip }) - mainClass.set(null as String?) -} -tasks.registerRunTask("runReobfPaperclip") { - description = "Spin up a test server from the reobf Paperclip jar" - classpath(rootProject.tasks.named("createReobfPaperclipJar").flatMap { it.outputZip }) - mainClass.set(null as String?) -}