From 7428998d71417f4d5592df8662d4632605221263 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 27 Feb 2022 22:43:06 -0600 Subject: [PATCH] Fix variable replacement by using Indra --- build-logic/src/main/kotlin/extensions.kt | 16 ---------------- core/build.gradle.kts | 10 +++++++--- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/build-logic/src/main/kotlin/extensions.kt b/build-logic/src/main/kotlin/extensions.kt index a2c90cd1f..ae8d578df 100644 --- a/build-logic/src/main/kotlin/extensions.kt +++ b/build-logic/src/main/kotlin/extensions.kt @@ -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().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") { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 1400c405f..b163d3794 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -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 { + val indra = the() + 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) } \ No newline at end of file