diff --git a/build-logic/src/main/kotlin/extensions.kt b/build-logic/src/main/kotlin/extensions.kt index 2cbbacc8..f1a05160 100644 --- a/build-logic/src/main/kotlin/extensions.kt +++ b/build-logic/src/main/kotlin/extensions.kt @@ -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().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") { relocate(pattern, "org.geysermc.floodgate.shaded.$pattern") diff --git a/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts b/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts index 168456d8..5ba172b0 100644 --- a/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts @@ -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" diff --git a/settings.gradle.kts b/settings.gradle.kts index 4ce62c32..11653aab 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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") }