Add manifest version

This commit is contained in:
2025-12-11 01:32:06 +01:00
parent 45b1c5ef1d
commit e63ece3aa0

View File

@@ -22,6 +22,20 @@ public class GitVersionService {
} }
private String resolveVersion() { private String resolveVersion() {
String gitDescribeVersion = tryGitDescribe();
if (gitDescribeVersion != null) {
return gitDescribeVersion;
}
String manifestVersion = getClass().getPackage().getImplementationVersion();
if (manifestVersion != null && !manifestVersion.isBlank()) {
return manifestVersion;
}
return "unknown";
}
private String tryGitDescribe() {
Process process = null; Process process = null;
try { try {
process = new ProcessBuilder("git", "describe", "--tags", "--always") process = new ProcessBuilder("git", "describe", "--tags", "--always")
@@ -36,7 +50,7 @@ public class GitVersionService {
LOG.warn("git describe returned exit code {} with output: {}", exitCode, result); LOG.warn("git describe returned exit code {} with output: {}", exitCode, result);
} }
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Unable to determine git version", e); LOG.warn("Unable to determine git version using git describe", e);
if (process != null) { if (process != null) {
process.destroyForcibly(); process.destroyForcibly();
} }
@@ -47,6 +61,6 @@ public class GitVersionService {
} }
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
return "unknown"; return null;
} }
} }