use grgit to resolve current commit

This commit is contained in:
Julian Krings 2025-07-23 18:06:52 +02:00
parent e5f2fee926
commit 16a4d20c90
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2
2 changed files with 6 additions and 5 deletions

View File

@ -26,6 +26,7 @@ plugins {
alias(libs.plugins.shadow)
alias(libs.plugins.sentry)
alias(libs.plugins.slimjar)
alias(libs.plugins.grgit)
}
val apiVersion = "1.19"
@ -139,11 +140,9 @@ tasks {
"main" to main,
"environment" to if (project.hasProperty("release")) "production" else "development",
"commit" to provider {
ProcessBuilder("git", "rev-parse", "HEAD")
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.start()
.inputStream.bufferedReader().readText().trim()
.takeIf { it.length == 40 } ?: "unknown"
runCatching { grgit.head().id }
.getOrDefault("")
.takeIf { it.length == 40 } ?: "unknown"
}
)
filesMatching("**/plugin.yml") {

View File

@ -9,6 +9,7 @@ slimjar = "2.0.8" # https://plugins.gradle.org/plugin/de.crazydev22.slimjar
download = "5.6.0" # https://plugins.gradle.org/plugin/de.undercouch.download
runPaper = "2.3.1" # https://plugins.gradle.org/plugin/xyz.jpenilla.run-paper
sentryPlugin = "5.8.0" # https://github.com/getsentry/sentry-android-gradle-plugin
grgit = "5.3.2" # https://github.com/ajoberstar/grgit
# Core Libraries
lombok = "1.18.38"
@ -100,3 +101,4 @@ slimjar = { id = "de.crazydev22.slimjar", version.ref = "slimjar" }
download = { id = "de.undercouch.download", version.ref = "download" }
runPaper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" }
sentry = { id = "io.sentry.jvm.gradle", version.ref = "sentryPlugin" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" }