3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 00:00:41 +01:00

Fix variable replacement by using Indra

Dieser Commit ist enthalten in:
RednedEpic 2022-02-27 22:43:06 -06:00
Ursprung b20546c515
Commit 7428998d71
2 geänderte Dateien mit 7 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -24,25 +24,9 @@
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.kyori.indra.git.IndraGitExtension
import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the
fun Project.lastCommitHash(): String? =
the<IndraGitExtension>().commit()?.name?.substring(0, 7)
// retrieved from https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project
// some properties might be specific to Jenkins
fun Project.branchName(): String =
System.getProperty("GIT_BRANCH", "local/dev")
fun Project.commitHashAbbrev(): String =
System.getProperty("GIT_COMMIT", "0000000")
fun Project.versionName(): String =
System.getProperty("GIT_VERSION", "local/dev")
fun Project.buildNumber(): Int =
Integer.parseInt(System.getProperty("BUILD_NUMBER", "-1"))
fun Project.relocate(pattern: String) {
tasks.named<ShadowJar>("shadowJar") {

Datei anzeigen

@ -1,7 +1,9 @@
import net.kyori.indra.git.IndraGitExtension
import net.kyori.blossom.BlossomExtension
plugins {
id("net.kyori.blossom")
id("net.kyori.indra.git")
}
dependencies {
@ -76,11 +78,13 @@ dependencies {
}
configure<BlossomExtension> {
val indra = the<IndraGitExtension>()
val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java"
val gitVersion = "git-${branchName()}-${commitHashAbbrev()}"
val gitVersion = "git-${indra.branchName()}-${indra.commit()?.name?.substring(0, 7)}"
replaceToken("\${version}", "${project.version} ($gitVersion)", mainFile)
replaceToken("\${gitVersion}", gitVersion, mainFile)
replaceToken("\${buildNumber}", buildNumber(), mainFile)
replaceToken("\${branch}", branchName(), mainFile)
replaceToken("\${buildNumber}", Integer.parseInt(System.getProperty("BUILD_NUMBER", "-1")), mainFile)
replaceToken("\${branch}", indra.branchName(), mainFile)
}