Added: Current Commit Hash (Thanks Booky)
This commit is contained in:
parent
e093a4ffc6
commit
2e684dd561
2 changed files with 22 additions and 2 deletions
|
@ -1,7 +1,27 @@
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
entitylib.`library-conventions`
|
entitylib.`library-conventions`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "me.tofaa.entitylib"
|
group = "me.tofaa.entitylib"
|
||||||
description = rootProject.name
|
description = rootProject.name
|
||||||
version = "2.4.1-SNAPSHOT"
|
val fullVersion = "2.4.1"
|
||||||
|
val snapshot = true
|
||||||
|
|
||||||
|
fun getVersionMeta(): String {
|
||||||
|
if (!snapshot) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var commitHash = ""
|
||||||
|
if (file(".git").isDirectory) {
|
||||||
|
val stdout = ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
commitHash = "+${stdout.toString().trim()}"
|
||||||
|
}
|
||||||
|
return "$commitHash-SNAPSHOT"
|
||||||
|
}
|
||||||
|
version = "$fullVersion${getVersionMeta()}"
|
|
@ -63,7 +63,7 @@ abstract class ELVersionTask : DefaultTask() {
|
||||||
val snapShot: Boolean
|
val snapShot: Boolean
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private val REGEX = Regex("""(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?""")
|
private val REGEX = Regex("""(\d+)\.(\d+)\.(\d+)(?:\+[0-9a-f]+)?(-SNAPSHOT)?""")
|
||||||
|
|
||||||
fun fromString(version: String): Version {
|
fun fromString(version: String): Version {
|
||||||
val match = REGEX.matchEntire(version) ?: throw IllegalArgumentException("Invalid version: $version")
|
val match = REGEX.matchEntire(version) ?: throw IllegalArgumentException("Invalid version: $version")
|
||||||
|
|
Loading…
Reference in a new issue