Skip to content

Commit

Permalink
Update paperweight to 2.0.0-beta.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Dec 20, 2024
1 parent fd1b6b1 commit 6e0c877
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 64 deletions.
29 changes: 16 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io.papermc.paperweight.util.*
import io.papermc.paperweight.util.constants.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import java.io.IOException
Expand All @@ -11,7 +12,7 @@ import java.nio.file.Path
import kotlin.random.Random

plugins {
id("io.papermc.paperweight.core") version "2.0.0-beta.5" apply false
id("io.papermc.paperweight.core") version "2.0.0-beta.6" apply false
}

subprojects {
Expand Down Expand Up @@ -146,19 +147,18 @@ tasks.register("checkWork") {
return Path.of(path.replaceFirst("^~".toRegex(), System.getProperty("user.home")))
}

val input = layout.cache.resolve("last-updating-folder").readText().trim()
val patchFolder = layout.projectDirectory.file("paper-server/patches/sources").convertToPath().resolve(input)
val sourceFolder = layout.projectDirectory.file("paper-server/src/vanilla/java/").convertToPath().resolve(input)
val targetFolder = expandUserHome(
providers.gradleProperty("cleanPaperRepo").orNull
?: error("cleanPaperRepo is required, define it in gradle.properties")
).resolve(input)
val input = providers.fileContents(layout.projectDirectory.file("$CACHE_PATH/last-updating-folder")).asText.map { it.trim() }
val patchFolder = layout.projectDirectory.dir("paper-server/patches/sources").dir(input)
val sourceFolder = layout.projectDirectory.dir("paper-server/src/vanilla/java").dir(input)
val targetFolder = providers.gradleProperty("cleanPaperRepo").map {
expandUserHome(it).resolve(input.get())
}

fun copy(back: Boolean = false) {
patchFolder.listDirectoryEntries().forEach {
val relative = patchFolder.relativize(it).toString().replace(".patch", "")
val source = sourceFolder.resolve(relative)
val target = targetFolder.resolve(relative)
patchFolder.path.listDirectoryEntries().forEach {
val relative = patchFolder.path.relativize(it).toString().replace(".patch", "")
val source = sourceFolder.path.resolve(relative)
val target = targetFolder.get().resolve(relative)
if (target.isDirectory()) { return@forEach }
if (back) {
target.copyTo(source, overwrite = true)
Expand All @@ -169,8 +169,11 @@ tasks.register("checkWork") {
}

doLast {
if (!targetFolder.isPresent) {
error("cleanPaperRepo is required, define it in gradle.properties")
}
copy()
val files = patchFolder.listDirectoryEntries().map { it.fileName.toString().replace(".patch", "") }
val files = patchFolder.path.listDirectoryEntries().map { it.fileName.toString().replace(".patch", "") }
println("Copied $files from $sourceFolder to $targetFolder")
println("Make the files compile, then press enter to copy them back!")
System.`in`.read()
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mcVersion=1.21.4
updatingMinecraft=false
updateTaskListIssue=https://github.com/PaperMC/Paper/issues/11736

# todo - bundler/paperclip tasks not compatible yet when using libraries
org.gradle.configuration-cache=false
org.gradle.configuration-cache=true
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.vfs.watch=false
98 changes: 49 additions & 49 deletions paper-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
dependencies {
mache("io.papermc:mache:1.21.4+build.6")
paperclip("io.papermc:paperclip:3.0.3")
remapper("net.fabricmc:tiny-remapper:0.10.3:fat")
}

paperweight {
Expand All @@ -23,23 +22,24 @@ paperweight {

paper {
reobfMappingsPatch = layout.projectDirectory.file("../build-data/reobf-mappings-patch.tiny")
reobfPackagesToFix.addAll(
"co.aikar.timings",
"com.destroystokyo.paper",
"com.mojang",
"io.papermc.paper",
"ca.spottedleaf",
"net.kyori.adventure.bossbar",
"net.minecraft",
"org.bukkit.craftbukkit",
"org.spigotmc",
)
}

spigot {
buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42"
packageVersion = "v1_21_R3" // also needs to be updated in MappingEnvironment
}

reobfPackagesToFix.addAll(
"co.aikar.timings",
"com.destroystokyo.paper",
"com.mojang",
"io.papermc.paper",
"ca.spottedleaf",
"net.kyori.adventure.bossbar",
"net.minecraft",
"org.bukkit.craftbukkit",
"org.spigotmc",
)
}

tasks.generateDevelopmentBundle {
Expand All @@ -58,45 +58,45 @@ abstract class Services {
}
val services = objects.newInstance<Services>()

publishing {
if (project.providers.gradleProperty("publishDevBundle").isPresent) {
val devBundleComponent = services.softwareComponentFactory.adhoc("devBundle")
components.add(devBundleComponent)
if (project.providers.gradleProperty("publishDevBundle").isPresent) {
val devBundleComponent = services.softwareComponentFactory.adhoc("devBundle")
components.add(devBundleComponent)

val devBundle = configurations.consumable("devBundle") {
attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.ZIP))
outgoing.artifact(tasks.generateDevelopmentBundle.flatMap { it.devBundleFile })
}
devBundleComponent.addVariantsFromConfiguration(devBundle.get()) {}
val devBundle = configurations.consumable("devBundle") {
attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.ZIP))
outgoing.artifact(tasks.generateDevelopmentBundle.flatMap { it.devBundleFile })
}
devBundleComponent.addVariantsFromConfiguration(devBundle.get()) {}

val runtime = configurations.consumable("serverRuntimeClasspath") {
attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.SERVER_DEPENDENCIES))
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
extendsFrom(configurations.runtimeClasspath.get())
}
devBundleComponent.addVariantsFromConfiguration(runtime.get()) {
mapToMavenScope("runtime")
}
val runtime = configurations.consumable("serverRuntimeClasspath") {
attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.SERVER_DEPENDENCIES))
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
extendsFrom(configurations.runtimeClasspath.get())
}
devBundleComponent.addVariantsFromConfiguration(runtime.get()) {
mapToMavenScope("runtime")
}

val compile = configurations.consumable("serverCompileClasspath") {
attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.SERVER_DEPENDENCIES))
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API))
extendsFrom(configurations.compileClasspath.get())
}
devBundleComponent.addVariantsFromConfiguration(compile.get()) {
mapToMavenScope("compile")
}
val compile = configurations.consumable("serverCompileClasspath") {
attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.SERVER_DEPENDENCIES))
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API))
extendsFrom(configurations.compileClasspath.get())
}
devBundleComponent.addVariantsFromConfiguration(compile.get()) {
mapToMavenScope("compile")
}

tasks.withType(GenerateMavenPom::class).configureEach {
doLast {
val text = destination.readText()
// Remove dependencies from pom, dev bundle is designed for gradle module metadata consumers
destination.writeText(
text.substringBefore("<dependencies>") + text.substringAfter("</dependencies>")
)
}
tasks.withType(GenerateMavenPom::class).configureEach {
doLast {
val text = destination.readText()
// Remove dependencies from pom, dev bundle is designed for gradle module metadata consumers
destination.writeText(
text.substringBefore("<dependencies>") + text.substringAfter("</dependencies>")
)
}
}

publishing {
publications.create<MavenPublication>("devBundle") {
artifactId = "dev-bundle"
from(devBundleComponent)
Expand Down Expand Up @@ -317,21 +317,21 @@ tasks.registerRunTask("runDevServer") {

tasks.registerRunTask("runBundler") {
description = "Spin up a test server from the Mojang mapped bundler jar"
classpath(tasks.named<io.papermc.paperweight.tasks.CreateBundlerJar>("createMojmapBundlerJar").flatMap { it.outputZip })
classpath(tasks.createMojmapBundlerJar.flatMap { it.outputZip })
mainClass.set(null as String?)
}
tasks.registerRunTask("runReobfBundler") {
description = "Spin up a test server from the reobf bundler jar"
classpath(tasks.named<io.papermc.paperweight.tasks.CreateBundlerJar>("createReobfBundlerJar").flatMap { it.outputZip })
classpath(tasks.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(tasks.named<io.papermc.paperweight.tasks.CreatePaperclipJar>("createMojmapPaperclipJar").flatMap { it.outputZip })
classpath(tasks.createMojmapPaperclipJar.flatMap { it.outputZip })
mainClass.set(null as String?)
}
tasks.registerRunTask("runReobfPaperclip") {
description = "Spin up a test server from the reobf Paperclip jar"
classpath(tasks.named<io.papermc.paperweight.tasks.CreatePaperclipJar>("createReobfPaperclipJar").flatMap { it.outputZip })
classpath(tasks.createReobfPaperclipJar.flatMap { it.outputZip })
mainClass.set(null as String?)
}

0 comments on commit 6e0c877

Please sign in to comment.