From 6ea86b6d0789910c19a9aeb8b7a5f23770e32038 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 11 Oct 2024 22:40:32 -0400 Subject: [PATCH] Get rootDir Signed-off-by: Craig Perkins --- .../main/java/org/opensearch/gradle/VersionProperties.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java b/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java index 74e5073862ede..dd73e41cbfdcc 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -143,7 +144,11 @@ private static void tomlVersionsToProperties(TomlTable tomlTable, Properties pro private static Properties getVersionProperties() { TomlParseResult toml = null; try { - Path path = Path.of(System.getProperty("user.dir"), "gradle/libs.versions.toml"); + Path rootDir = Paths.get(System.getProperty("user.dir")); + if (rootDir.endsWith("buildSrc")) { + rootDir = rootDir.getParent(); + } + Path path = rootDir.resolve("gradle/libs.versions.toml"); toml = Toml.parse(path); } catch (IOException e) { throw new RuntimeException(e);