1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Use different version format for snapshots

This commit is contained in:
Tim203
2022-03-02 21:05:50 +01:00
parent 3950824532
commit b447fcbbff
3 changed files with 13 additions and 3 deletions

View File

@@ -30,6 +30,14 @@ import org.gradle.api.artifacts.ProjectDependency
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the
fun Project.fullVersion(): String {
var version = version.toString()
if (version.endsWith("-SNAPSHOT")) {
version += " (b${buildNumberAsString()}-${lastCommitHash()}}"
}
return version
}
fun Project.lastCommitHash(): String? =
the<IndraGitExtension>().commit()?.name?.substring(0, 7)
@@ -40,6 +48,9 @@ fun Project.branchName(): String =
fun Project.buildNumber(): Int =
Integer.parseInt(System.getProperty("BUILD_NUMBER", "-1"))
fun Project.buildNumberAsString(): String =
buildNumber().takeIf { it != -1 }?.toString() ?: "??"
fun Project.relocate(pattern: String) {
tasks.named<ShadowJar>("shadowJar") {
relocate(pattern, "org.geysermc.floodgate.shaded.$pattern")

View File

@@ -2,6 +2,7 @@ plugins {
`java-library`
`maven-publish`
// id("net.ltgt.errorprone")
id("net.kyori.indra.git")
}
dependencies {
@@ -14,7 +15,7 @@ tasks {
expand(
"id" to "floodgate",
"name" to "floodgate",
"version" to project.version,
"version" to fullVersion(),
"description" to project.description,
"url" to "https://geysermc.org",
"author" to "GeyserMC"

View File

@@ -42,8 +42,6 @@ pluginManagement {
}
plugins {
id("net.kyori.blossom") version "1.2.0"
id("net.kyori.indra")
id("net.kyori.indra.git")
}
includeBuild("build-logic")
}