Extract version number from git

This commit is contained in:
Johannes Frohnmeyer 2021-12-27 14:39:24 +01:00
parent 9200ee2e2e
commit f77d8709ae
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 15 additions and 2 deletions

View File

@ -5,6 +5,7 @@ plugins {
id 'application'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id "maven-publish"
id "org.ajoberstar.grgit" version "3.1.0"
}
application {
@ -15,8 +16,21 @@ repositories {
mavenCentral()
}
ext.currentVer = "0.0.0+nogit"
if (grgit != null) {
ext.currentVer = "0.0.0+notag"
grgit.open(dir: rootProject.projectDir.toString())
def tagList = grgit.tag.list()
tagList.sort((left, right) -> right.commit.dateTime.compareTo(left.commit.dateTime))
if (tagList.size() >= 1) {
ext.currentVer = tagList.get(0).getName()
}
}
println("Building Inceptum " + ext.currentVer)
allprojects {
version "$project.ver" + (project.hasProperty('release') ? "" : "-" + (project.hasProperty('timestamp') ? project.getProperty('timestamp') : Instant.now().getEpochSecond()))
version "$rootProject.ext.currentVer" + (project.hasProperty('release') ? "" : "-" + (project.hasProperty('timestamp') ? project.getProperty('timestamp') : Instant.now().getEpochSecond()))
group 'io.gitlab.jfronny.inceptum'
}

View File

@ -1 +0,0 @@
ver=0.1