From ff75689b0802180538e6dba36d113e7529e43139 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:50:30 -0700 Subject: [PATCH] Adjust build for config cache compat --- gradle.properties | 1 + paper-api/build.gradle.kts | 12 ++++++++++-- paper-server/build.gradle.kts | 20 ++++++++++++-------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 192e0e5f62..8989546485 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,7 @@ updatingMinecraft=false #cleanPaperRepo=F:\\Projects\\Paper121\\Paper-Server\\src\\main\\java updateTaskListIssue=https://github.com/PaperMC/testing/issues/2 +org.gradle.configuration-cache=true org.gradle.caching=true org.gradle.parallel=true org.gradle.vfs.watch=false diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index 571534b42c..832a2b3e86 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -161,6 +161,12 @@ tasks.jar { } } +abstract class Services { + @get:Inject + abstract val fileSystemOperations: FileSystemOperations +} +val services = objects.newInstance() + tasks.withType { val options = options as StandardJavadocDocletOptions options.overview = "src/main/javadoc/overview.html" @@ -192,17 +198,19 @@ tasks.withType { options.tags("apiNote:a:API Note:") inputs.files(apiAndDocs).ignoreEmptyDirectories().withPropertyName(apiAndDocs.name + "-configuration") + val apiAndDocsElements = apiAndDocs.elements doFirst { options.addStringOption( "sourcepath", - apiAndDocs.elements.get().map { it.asFile }.joinToString(separator = File.pathSeparator, transform = File::getPath) + apiAndDocsElements.get().map { it.asFile }.joinToString(separator = File.pathSeparator, transform = File::getPath) ) } // workaround for https://github.com/gradle/gradle/issues/4046 inputs.dir("src/main/javadoc").withPropertyName("javadoc-sourceset") + val fsOps = services.fileSystemOperations doLast { - copy { + fsOps.copy { from("src/main/javadoc") { include("**/doc-files/**") } diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 43be6233eb..7a8c6d0fbf 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -49,15 +49,18 @@ tasks.generateDevelopmentBundle { ) } -abstract class SoftwareComponentFactoryProvider { +abstract class Services { @get:Inject - abstract val factory: SoftwareComponentFactory + abstract val softwareComponentFactory: SoftwareComponentFactory + + @get:Inject + abstract val archiveOperations: ArchiveOperations } -val provider = objects.newInstance() +val services = objects.newInstance() publishing { if (project.providers.gradleProperty("publishDevBundle").isPresent) { - val devBundleComponent = provider.factory.adhoc("devBundle") + val devBundleComponent = services.softwareComponentFactory.adhoc("devBundle") components.add(devBundleComponent) val devBundle = configurations.consumable("devBundle") { @@ -179,10 +182,10 @@ tasks.jar { 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 gitHash = git.exec(providers, "rev-parse", "--short=7", "HEAD").get().trim() val implementationVersion = "$mcVersion-${build ?: "DEV"}-$gitHash" - val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper - val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper + val date = git.exec(providers, "show", "-s", "--format=%ci", gitHash).get().trim() // Paper + val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() // Paper attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "Paper", @@ -222,10 +225,11 @@ tasks.check { // Paper end // Paper start - use TCA for console improvements tasks.jar { + val archiveOperations = services.archiveOperations from(alsoShade.elements.map { it.map { f -> if (f.asFile.isFile) { - zipTree(f.asFile) + archiveOperations.zipTree(f.asFile) } else { f.asFile }