From e194d4db7635a1b13ea2df8b330202ad037cf50b Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Mon, 29 Apr 2024 17:16:14 +0200 Subject: [PATCH] get version from txt file --- .../java/co/elastic/clients/transport/Version.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/java-client/src/main/java/co/elastic/clients/transport/Version.java b/java-client/src/main/java/co/elastic/clients/transport/Version.java index 142e608eb..3c4a81755 100644 --- a/java-client/src/main/java/co/elastic/clients/transport/Version.java +++ b/java-client/src/main/java/co/elastic/clients/transport/Version.java @@ -20,6 +20,10 @@ package co.elastic.clients.transport; import javax.annotation.Nullable; +import java.io.BufferedReader; +import java.io.FileReader; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Objects; /** @@ -146,8 +150,14 @@ public String toString() { static { Version version = null; - try { - version = Version.parse(VersionInfo.VERSION); + String dir = System.getProperty("user.dir"); + String filename = "version.txt"; + if(VersionInfo.FLAVOR.equals("serverless")){ + filename = "version-serverless.txt"; + } + Path path = Paths.get(dir, "config", filename); + try(BufferedReader vsReader = new BufferedReader(new FileReader(path.toFile()))) { + version = Version.parse(vsReader.readLine()); } catch (Exception e) { // Failed to parse version }