Add git branch and first 7 of hash to version when version is a snapshot

This commit is contained in:
Vankka 2023-12-20 21:14:42 +02:00
parent 9bfc5c8be1
commit 37bddcbe81
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0

View File

@ -17,8 +17,20 @@ subprojects {
apply plugin: 'net.kyori.indra.git'
apply plugin: 'dev.vankka.dependencydownload.plugin'
var versionExtra = ""
if (rootProject.version.startsWith("-SNAPSHOT") && indraGit.isPresent()) {
var branch = indraGit.branchName()
if (branch == null) {
branch = "detached-head"
}
var gitHash = indraGit.commit().getName()
if (gitHash.length() > 7) {
gitHash = gitHash.substring(0, 7);
}
versionExtra = "-" + branch + "-" + gitHash
}
group 'com.discordsrv'
version = rootProject.version
version = rootProject.version + versionExtra
java {
sourceCompatibility = JavaVersion.VERSION_1_8