Skip to content

Commit 2f990e7

Browse files
committed
get version from txt file
1 parent af747b2 commit 2f990e7

File tree

1 file changed

+12
-2
lines changed
  • java-client/src/main/java/co/elastic/clients/transport

1 file changed

+12
-2
lines changed

java-client/src/main/java/co/elastic/clients/transport/Version.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
package co.elastic.clients.transport;
2121

2222
import javax.annotation.Nullable;
23+
import java.io.BufferedReader;
24+
import java.io.FileReader;
25+
import java.nio.file.Path;
26+
import java.nio.file.Paths;
2327
import java.util.Objects;
2428

2529
/**
@@ -146,8 +150,14 @@ public String toString() {
146150

147151
static {
148152
Version version = null;
149-
try {
150-
version = Version.parse(VersionInfo.VERSION);
153+
String dir = System.getProperty("user.dir");
154+
String filename = "version.txt";
155+
if(VersionInfo.FLAVOR.equals("serverless")){
156+
filename = "version-serverless.txt";
157+
}
158+
Path path = Paths.get(dir, "config", filename);
159+
try(BufferedReader vsReader = new BufferedReader(new FileReader(path.toFile()))) {
160+
version = Version.parse(vsReader.readLine());
151161
} catch (Exception e) {
152162
// Failed to parse version
153163
}

0 commit comments

Comments
 (0)