Browse Source

Fix file path when looking for docker exclusions file (#105304)

Mark Vieira 1 year ago
parent
commit
6c4e55e714

+ 18 - 18
build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/util/Util.java

@@ -119,29 +119,29 @@ public class Util {
         return project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
     }
 
-        public static File locateElasticsearchWorkspace(Gradle gradle) {
-            if(gradle.getRootProject().getName().startsWith("build-tools")) {
-                File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
-                if(versionFileExists(buildToolsParent)) {
-                    return buildToolsParent;
-                }
+    public static File locateElasticsearchWorkspace(Gradle gradle) {
+        if (gradle.getRootProject().getName().startsWith("build-tools")) {
+            File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
+            if (versionFileExists(buildToolsParent)) {
                 return buildToolsParent;
             }
-            if (gradle.getParent() == null) {
-                // See if any of these included builds is the Elasticsearch gradle
-                for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
-                    if (versionFileExists(includedBuild.getProjectDir())) {
-                        return includedBuild.getProjectDir();
-                    }
+            return buildToolsParent;
+        }
+        if (gradle.getParent() == null) {
+            // See if any of these included builds is the Elasticsearch gradle
+            for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
+                if (versionFileExists(includedBuild.getProjectDir())) {
+                    return includedBuild.getProjectDir();
                 }
-
-                // Otherwise assume this gradle is the root elasticsearch workspace
-                return gradle.getRootProject().getRootDir();
-            } else {
-                // We're an included build, so keep looking
-                return locateElasticsearchWorkspace(gradle.getParent());
             }
+
+            // Otherwise assume this gradle is the root elasticsearch workspace
+            return gradle.getRootProject().getRootDir();
+        } else {
+            // We're an included build, so keep looking
+            return locateElasticsearchWorkspace(gradle.getParent());
         }
+    }
 
     private static boolean versionFileExists(File rootDir) {
         return new File(rootDir, "build-tools-internal/version.properties").exists();

+ 1 - 0
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java

@@ -144,6 +144,7 @@ public class ElasticsearchTestBasePlugin implements Plugin<Project> {
             // don't track these as inputs since they contain absolute paths and break cache relocatability
             File gradleUserHome = project.getGradle().getGradleUserHomeDir();
             nonInputProperties.systemProperty("gradle.user.home", gradleUserHome);
+            nonInputProperties.systemProperty("workspace.dir", Util.locateElasticsearchWorkspace(project.getGradle()));
             // we use 'temp' relative to CWD since this is per JVM and tests are forbidden from writing to CWD
             nonInputProperties.systemProperty("java.io.tmpdir", test.getWorkingDir().toPath().resolve("temp"));
 

+ 1 - 1
test/fixtures/testcontainer-utils/src/main/java/org/elasticsearch/test/fixtures/testcontainers/DockerEnvironmentAwareTestContainer.java

@@ -115,7 +115,7 @@ public abstract class DockerEnvironmentAwareTestContainer extends GenericContain
     }
 
     private static List<String> getLinuxExclusionList() {
-        File exclusionsFile = new File(DOCKER_ON_LINUX_EXCLUSIONS_FILE);
+        File exclusionsFile = new File(System.getProperty("workspace.dir"), DOCKER_ON_LINUX_EXCLUSIONS_FILE);
         if (exclusionsFile.exists()) {
             try {
                 return Files.readAllLines(exclusionsFile.toPath())