diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-15 00:27:53 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-15 18:40:20 +0100 |
commit | f158a9d8b06834e5ab132e658913a7535175d0aa (patch) | |
tree | 079797365d7098f9c42c1946b8ccb323863f556c /buildSrc/src | |
parent | 2c8152335e600187d18edbd7f53760efda0399b1 (diff) | |
download | Firmament-f158a9d8b06834e5ab132e658913a7535175d0aa.tar.gz Firmament-f158a9d8b06834e5ab132e658913a7535175d0aa.tar.bz2 Firmament-f158a9d8b06834e5ab132e658913a7535175d0aa.zip |
build: Upgrade versioning to handle multiple minecraft versions
Diffstat (limited to 'buildSrc/src')
-rw-r--r-- | buildSrc/src/lookupversion.kt | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/buildSrc/src/lookupversion.kt b/buildSrc/src/lookupversion.kt index 53b2df9..0f1b0c1 100644 --- a/buildSrc/src/lookupversion.kt +++ b/buildSrc/src/lookupversion.kt @@ -1,26 +1,25 @@ - fun execString(vararg args: String): String { - val pb = ProcessBuilder(*args) - .redirectOutput(ProcessBuilder.Redirect.PIPE) - .start() - pb.waitFor() - return pb.inputStream.readAllBytes().decodeToString().trim() + val pb = ProcessBuilder(*args) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .start() + pb.waitFor() + return pb.inputStream.readAllBytes().decodeToString().trim() } -private val tag = "([0-9.]+)\\.0".toRegex() -private val tagOffset = "([0-9.]+)\\.0-([0-9]+)..+".toRegex() +private val tag = "([0-9.]+)(?:\\+.*)?".toRegex() +private val tagOffset = "([0-9.]+)(?:\\+.*)?-([0-9]+)-(.+)".toRegex() inline fun <T> Regex.useMatcher(string: String, block: (MatchResult) -> T): T? { - return matchEntire(string)?.let(block) + return matchEntire(string)?.let(block) } -fun getGitTagInfo(): String { - val str = execString("git", "describe", "--tags", "HEAD") - tag.useMatcher(str) { - return it.groupValues[0] - } - tagOffset.useMatcher(str) { - return it.groupValues[1] + "." + it.groupValues[2] - } - return "nogitversion" +fun getGitTagInfo(mcVersion: String): String { + val str = execString("git", "describe", "--tags", "HEAD") + tag.useMatcher(str) { + return it.groupValues[1] + "+mc$mcVersion" + } + tagOffset.useMatcher(str) { + return it.groupValues[1] + "-dev+mc$mcVersion+" + it.groupValues[3] + } + return "nogitversion+mc$mcVersion" } |