From bcd6ac6fcb055a94a0eccc3f495e07b57f831816 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:39:15 -0600 Subject: [PATCH] create version file --- gradle/app-version.gradle | 23 +++++++++++++++++++++++ 1 file changed, 23 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..026c82f --- /dev/null +++ b/gradle/app-version.gradle @@ -0,0 +1,23 @@ +apply plugin: "com.palantir.git-version" + +tasks.withType(JavaCompile) { + doFirst { + def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-ws-version.json") + new File(versionFile.getParent()).mkdirs() + def details = versionDetails() + def ciProjectUrl = System.getenv("CI_PROJECT_URL") + def versionInfo = [ + branchName: details.branchName, + commitDistance: details.commitDistance, + gitHash: details.gitHash, + gitHashFull: details.gitHashFull, + isCleanTag: details.isCleanTag, + lastTag: details.lastTag, + projectName: project.name, + 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