Adjust build for config cache compat

This commit is contained in:
Jason Penilla 2024-12-09 12:50:30 -07:00 committed by Nassim Jahnke
parent 8da8d2991f
commit ff75689b08
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F
3 changed files with 23 additions and 10 deletions

View file

@ -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

View file

@ -161,6 +161,12 @@ tasks.jar {
}
}
abstract class Services {
@get:Inject
abstract val fileSystemOperations: FileSystemOperations
}
val services = objects.newInstance<Services>()
tasks.withType<Javadoc> {
val options = options as StandardJavadocDocletOptions
options.overview = "src/main/javadoc/overview.html"
@ -192,17 +198,19 @@ tasks.withType<Javadoc> {
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/**")
}

View file

@ -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<SoftwareComponentFactoryProvider>()
val services = objects.newInstance<Services>()
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
}