mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Fix variable replacement by using Indra
This commit is contained in:
parent
b20546c515
commit
7428998d71
2 changed files with 7 additions and 19 deletions
|
@ -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") {
|
||||
|
|
|
@ -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)
|
||||
}
|
Loading…
Reference in a new issue