Skip to content

Commit a80766d

Browse files
committed
version file moved / fetching adapted
1 parent 4f7bf06 commit a80766d

3 files changed

Lines changed: 10 additions & 18 deletions

File tree

version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

zsmith/src/main/java/airhacks/zsmith/agent/control/Version.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,31 @@
33
import java.nio.file.Files;
44
import java.nio.file.Path;
55

6-
public class Version {
6+
public interface Version {
77

8-
static final String VERSION_FILE = "/version.txt";
9-
static final Path[] FALLBACK_PATHS = {
10-
Path.of("src/main/resources/version.txt"),
11-
Path.of("zsmith/src/main/resources/version.txt")
12-
};
8+
String versionFile = "version.txt";
9+
Path versionPath = Path.of(versionFile);
1310

1411
public static String current() {
1512
var fromManifest = Version.class.getPackage().getImplementationVersion();
1613
if (fromManifest != null) {
1714
return fromManifest.strip();
1815
}
19-
try (var in = Version.class.getResourceAsStream(VERSION_FILE)) {
16+
try (var in = Version.class.getResourceAsStream(versionFile)) {
2017
if (in != null) {
2118
return new String(in.readAllBytes()).strip();
2219
}
2320
} catch (Exception e) {
24-
throw new IllegalStateException("Cannot read " + VERSION_FILE + " from classpath", e);
21+
throw new IllegalStateException("Cannot read " + versionPath + " from classpath", e);
2522
}
2623
return fromFilesystem();
2724
}
2825

2926
static String fromFilesystem() {
30-
for (var path : FALLBACK_PATHS) {
31-
if (Files.exists(path)) {
32-
try {
33-
return Files.readString(path).strip();
34-
} catch (Exception e) {
35-
throw new IllegalStateException("Cannot read " + path, e);
36-
}
37-
}
27+
try {
28+
return Files.readString(versionPath).strip();
29+
} catch (Exception e) {
30+
throw new IllegalStateException("Cannot read " + versionPath, e);
3831
}
39-
throw new IllegalStateException("version.txt not found on classpath or in " + java.util.Arrays.toString(FALLBACK_PATHS));
4032
}
4133
}

zsmith/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026.04.28.02

0 commit comments

Comments
 (0)