Only include build time in manifest for numbered builds

This commit is contained in:
Jason Penilla 2024-12-17 19:41:47 -08:00
parent c55ad7092c
commit e97bf6933c
No known key found for this signature in database
GPG key ID: 0E75A301420E48F8

View file

@ -181,12 +181,12 @@ dependencies {
// Paper end - spark // Paper end - spark
} }
tasks.jar { tasks.jar {
manifest { manifest {
val git = Git(rootProject.layout.projectDirectory.path) val git = Git(rootProject.layout.projectDirectory.path)
val mcVersion = rootProject.providers.gradleProperty("mcVersion").get() val mcVersion = rootProject.providers.gradleProperty("mcVersion").get()
val build = System.getenv("BUILD_NUMBER") ?: null val build = System.getenv("BUILD_NUMBER") ?: null
val buildTime = if (build != null) Instant.now() else Instant.EPOCH
val gitHash = git.exec(providers, "rev-parse", "--short=7", "HEAD").get().trim() val gitHash = git.exec(providers, "rev-parse", "--short=7", "HEAD").get().trim()
val implementationVersion = "$mcVersion-${build ?: "DEV"}-$gitHash" val implementationVersion = "$mcVersion-${build ?: "DEV"}-$gitHash"
val date = git.exec(providers, "show", "-s", "--format=%ci", gitHash).get().trim() // Paper val date = git.exec(providers, "show", "-s", "--format=%ci", gitHash).get().trim() // Paper
@ -202,7 +202,7 @@ tasks.jar {
"Brand-Id" to "papermc:paper", "Brand-Id" to "papermc:paper",
"Brand-Name" to "Paper", "Brand-Name" to "Paper",
"Build-Number" to (build ?: ""), "Build-Number" to (build ?: ""),
"Build-Time" to Instant.now().toString(), "Build-Time" to buildTime.toString(),
"Git-Branch" to gitBranch, // Paper "Git-Branch" to gitBranch, // Paper
"Git-Commit" to gitHash, // Paper "Git-Commit" to gitHash, // Paper
) )