build script updates

This commit is contained in:
Jason Penilla 2023-12-06 11:48:37 -07:00
parent deb02722b2
commit 05148728de
No known key found for this signature in database
GPG Key ID: 0E75A301420E48F8
1 changed files with 25 additions and 18 deletions

View File

@ -20,7 +20,7 @@ allprojects {
java { java {
toolchain { toolchain {
languageVersion.set(JavaLanguageVersion.of(17)) languageVersion = JavaLanguageVersion.of(17)
} }
} }
} }
@ -30,7 +30,7 @@ val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
subprojects { subprojects {
tasks.withType<JavaCompile> { tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name() options.encoding = Charsets.UTF_8.name()
options.release.set(17) options.release = 17
} }
tasks.withType<Javadoc> { tasks.withType<Javadoc> {
options.encoding = Charsets.UTF_8.name() options.encoding = Charsets.UTF_8.name()
@ -75,23 +75,23 @@ dependencies {
} }
paperweight { paperweight {
minecraftVersion.set(providers.gradleProperty("mcVersion")) minecraftVersion = providers.gradleProperty("mcVersion")
serverProject.set(project(":paper-server")) serverProject = project(":paper-server")
paramMappingsRepo.set(paperMavenPublicUrl) paramMappingsRepo = paperMavenPublicUrl
remapRepo.set(paperMavenPublicUrl) remapRepo = paperMavenPublicUrl
decompileRepo.set(paperMavenPublicUrl) decompileRepo = paperMavenPublicUrl
craftBukkit { craftBukkit {
fernFlowerJar.set(layout.file(spigotDecompiler.elements.map { it.single().asFile })) fernFlowerJar = layout.file(spigotDecompiler.elements.map { it.single().asFile })
} }
paper { paper {
spigotApiPatchDir.set(layout.projectDirectory.dir("patches/api")) spigotApiPatchDir = layout.projectDirectory.dir("patches/api")
spigotServerPatchDir.set(layout.projectDirectory.dir("patches/server")) spigotServerPatchDir = layout.projectDirectory.dir("patches/server")
mappingsPatch.set(layout.projectDirectory.file("build-data/mappings-patch.tiny")) mappingsPatch = layout.projectDirectory.file("build-data/mappings-patch.tiny")
reobfMappingsPatch.set(layout.projectDirectory.file("build-data/reobf-mappings-patch.tiny")) reobfMappingsPatch = layout.projectDirectory.file("build-data/reobf-mappings-patch.tiny")
reobfPackagesToFix.addAll( reobfPackagesToFix.addAll(
"co.aikar.timings", "co.aikar.timings",
@ -108,8 +108,8 @@ paperweight {
} }
tasks.generateDevelopmentBundle { tasks.generateDevelopmentBundle {
apiCoordinates.set("io.papermc.paper:paper-api") apiCoordinates = "io.papermc.paper:paper-api"
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi") mojangApiCoordinates = "io.papermc.paper:paper-mojangapi"
libraryRepositories.addAll( libraryRepositories.addAll(
"https://repo.maven.apache.org/maven2/", "https://repo.maven.apache.org/maven2/",
paperMavenPublicUrl, paperMavenPublicUrl,
@ -152,16 +152,20 @@ tasks.register("printPaperVersion") {
// see gradle.properties // see gradle.properties
if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) { if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) {
tasks.collectAtsFromPatches { tasks.collectAtsFromPatches {
extraPatchDir.set(layout.projectDirectory.dir("patches/unapplied/server")) val dir = layout.projectDirectory.dir("patches/unapplied/server")
if (dir.path.isDirectory()) {
extraPatchDir = dir
}
} }
tasks.withType<io.papermc.paperweight.tasks.RebuildGitPatches>().configureEach { tasks.withType<io.papermc.paperweight.tasks.RebuildGitPatches>().configureEach {
filterPatches.set(false) filterPatches = false
} }
tasks.register("continueServerUpdate", RebasePatches::class) { tasks.register("continueServerUpdate", RebasePatches::class) {
description = "Moves the next X patches from unapplied to applied, and applies them. X being the number of patches that apply cleanly, plus the terminal failure if any." description = "Moves the next X patches from unapplied to applied, and applies them. X being the number of patches that apply cleanly, plus the terminal failure if any."
projectDir = project.projectDir projectDir = project.projectDir
appliedPatches = file("patches/server") appliedPatches = file("patches/server")
unappliedPatches = file("patches/unapplied/server") unappliedPatches = file("patches/unapplied/server")
applyTaskName = "applyServerPatches"
} }
} }
@ -176,6 +180,9 @@ abstract class RebasePatches : BaseTask() {
@get:InputFiles @get:InputFiles
abstract val unappliedPatches: DirectoryProperty abstract val unappliedPatches: DirectoryProperty
@get:Input
abstract val applyTaskName: Property<String>
private fun unapplied(): List<Path> = private fun unapplied(): List<Path> =
unappliedPatches.path.listDirectoryEntries("*.patch").sortedBy { it.name } unappliedPatches.path.listDirectoryEntries("*.patch").sortedBy { it.name }
@ -196,7 +203,7 @@ abstract class RebasePatches : BaseTask() {
val out = ByteArrayOutputStream() val out = ByteArrayOutputStream()
val proc = ProcessBuilder() val proc = ProcessBuilder()
.directory(projectDir.path) .directory(projectDir.path)
.command("./gradlew", "applyServerPatches") .command("./gradlew", applyTaskName.get())
.redirectErrorStream(true) .redirectErrorStream(true)
.start() .start()
@ -240,7 +247,7 @@ abstract class RebasePatches : BaseTask() {
// Apply again to reset the am session (so it ends on the failed patch, to allow us to rebuild after fixing it) // Apply again to reset the am session (so it ends on the failed patch, to allow us to rebuild after fixing it)
val apply2 = ProcessBuilder() val apply2 = ProcessBuilder()
.directory(projectDir.path) .directory(projectDir.path)
.command("./gradlew", "applyServerPatches") .command("./gradlew", applyTaskName.get())
.redirectErrorStream(true) .redirectErrorStream(true)
.start() .start()