diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle new file mode 100644 index 0000000000000000000000000000000000000000..026c82fc57203d83ae20f3a04df4156a91bdadcf --- /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)) + } +}