From e56a90352f91c35b34e44ee99cb7faf31859fd2e Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 17:06:35 -0600 Subject: [PATCH] create app version file --- gradle/app-version.gradle | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gradle/app-version.gradle diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle new file mode 100644 index 0000000..444062b --- /dev/null +++ b/gradle/app-version.gradle @@ -0,0 +1,24 @@ +apply plugin: "com.palantir.git-version" + +tasks.withType(JavaCompile) { + doFirst { + def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-ws-static-version.json") + new File(versionFile.getParent()).mkdirs() + def details = versionDetails() + def ciProjectUrl = System.getenv("CI_PROJECT_URL") + def branch = System.getenv("CI_COMMIT_BRANCH") + def versionInfo = [ + branchName: branch ? branch : details.branchName, + commitDistance: details.commitDistance, + gitHash: details.gitHash, + gitHashFull: details.gitHashFull, + isCleanTag: details.isCleanTag, + lastTag: details.lastTag, + projectName: root, + url: ciProjectUrl ? ciProjectUrl : 'git config --get remote.origin.url'.execute().text.replace('\n', ''), + version: details.version, + ] + def json = groovy.json.JsonOutput.toJson(versionInfo) + versionFile.write(groovy.json.JsonOutput.prettyPrint(json)) + } +} -- GitLab