Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ plugins {


def getDevelopmentVersion() {
def output = new StringBuilder()
def error = new StringBuilder()
def gitCheckOutput = new StringBuilder()
def gitCheckError = new StringBuilder()
def gitCheck = ["git", "rev-parse", "--is-inside-work-tree"].execute()
gitCheck.waitForProcessOutput(gitCheckOutput, gitCheckError)
def isGit = gitCheckOutput.toString().trim()
if (isGit != "true") {
def version = "0.0.0-" + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-no-git"
println "created development version: $version"
return version
}

def gitHashOutput = new StringBuilder()
def gitHashError = new StringBuilder()
def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute()
gitShortHash.waitForProcessOutput(output, error)
def gitHash = output.toString().trim()
gitShortHash.waitForProcessOutput(gitHashOutput, gitHashError)
def gitHash = gitHashOutput.toString().trim()
if (gitHash.isEmpty()) {
println "git hash is empty: error: ${error.toString()}"
throw new IllegalStateException("git hash could not be determined")
Expand Down