From 757caa635a9edaf57331d1a9713a00076f5d236b Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Tue, 19 Apr 2022 15:02:38 -0600 Subject: [PATCH] add properties --- build.gradle | 13 ++++++++++++- .../gov/usgs/earthquake/nshmp/internal/Version.java | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index f00a9e11..b578177a 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,18 @@ jar { def versionPath = "/resources/main/version.json" def versionFile = new File(project.buildDir.toString() + versionPath) def details = versionDetails() - def json = groovy.json.JsonOutput.toJson(details) + def versionInfo = [ + branchName: details.branchName, + commitDistance: details.commitDistance, + gitHash: details.gitHash, + gitHashFull: details.gitHashFull, + isCleanTag: details.isCleanTag, + lastTag: details.lastTag, + projectName: project.name, + version: details.version, + url: 'git config --get remote.origin.url'.execute().text.replace('\n', '') + ] + def json = groovy.json.JsonOutput.toJson(versionInfo) versionFile.write(groovy.json.JsonOutput.prettyPrint(json)) } } diff --git a/src/main/java/gov/usgs/earthquake/nshmp/internal/Version.java b/src/main/java/gov/usgs/earthquake/nshmp/internal/Version.java index 31280f63..4ecd4e44 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/internal/Version.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/internal/Version.java @@ -4,11 +4,10 @@ import com.google.common.io.Resources; import com.google.gson.Gson; public class Version { - private static final Gson GSON = new Gson(); public static VersionInfo getVersionInfo() throws IllegalArgumentException { var resource = Resources.getResource("version.json"); - return GSON.fromJson(resource.toString(), VersionInfo.class); + return new Gson().fromJson(resource.toString(), VersionInfo.class); } public static class VersionInfo { @@ -18,5 +17,7 @@ public class Version { public String gitHashFull; public boolean isCleanTag; public String lastTag; + public String version; + public String url; } } -- GitLab