Remove git versioning

This commit is contained in:
2026-01-01 17:14:26 +01:00
parent fa3c30fdac
commit 98c655d9a0

View File

@@ -4,9 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@Component
public class VersionService {
@@ -28,21 +26,11 @@ public class VersionService {
}
private String resolveVersion() {
String manifestVersion = getClass().getPackage().getImplementationVersion();
if (manifestVersion != null && !manifestVersion.isBlank()) {
return manifestVersion;
}
String pomVersion = getPomVersion();
if (pomVersion != null && !pomVersion.isBlank()) {
return pomVersion;
}
String gitDescribeVersion = getGitVersionString();
if (gitDescribeVersion != null) {
return "git-" + gitDescribeVersion;
}
return "unknown";
}
@@ -52,7 +40,6 @@ public class VersionService {
}
String normalized = baseVersion.trim();
normalized = normalized.replaceFirst("^git-", "");
normalized = normalized.replaceFirst("(?i)^v", "");
normalized = normalized.replaceFirst("-SNAPSHOT$", "");
if (normalized.isBlank()) {
@@ -77,47 +64,4 @@ public class VersionService {
}
return null;
}
private String getGitVersionString() {
try {
Process check = new ProcessBuilder("git", "--version")
.redirectErrorStream(true)
.start();
if (check.waitFor() != 0) {
LOG.info("git not found on PATH, skipping git version detection");
return null;
}
} catch (Exception e) {
LOG.info("git not found on PATH, skipping git version detection");
return null;
}
Process process = null;
try {
process = new ProcessBuilder("git", "describe", "--tags", "--always")
.redirectErrorStream(true)
.start();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String result = reader.readLine();
int exitCode = process.waitFor();
if (exitCode == 0 && result != null && !result.isBlank()) {
return result.trim();
}
LOG.warn("git describe returned exit code {} with output: {}", exitCode, result);
}
} catch (IOException e) {
LOG.warn("Unable to determine git version using git describe", e);
if (process != null) {
process.destroyForcibly();
}
} catch (InterruptedException e) {
LOG.warn("Interrupted while determining git version", e);
if (process != null) {
process.destroyForcibly();
}
Thread.currentThread().interrupt();
}
return null;
}
}