Skip to content

Commit 4ec35be

Browse files
authored
Fix file path when looking for docker exclusions file (#105304) (#105309)
1 parent 9804e0e commit 4ec35be

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,29 @@ public static SourceSetContainer getJavaSourceSets(Project project) {
119119
return project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
120120
}
121121

122-
public static File locateElasticsearchWorkspace(Gradle gradle) {
123-
if(gradle.getRootProject().getName().startsWith("build-tools")) {
124-
File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
125-
if(versionFileExists(buildToolsParent)) {
126-
return buildToolsParent;
127-
}
122+
public static File locateElasticsearchWorkspace(Gradle gradle) {
123+
if (gradle.getRootProject().getName().startsWith("build-tools")) {
124+
File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
125+
if (versionFileExists(buildToolsParent)) {
128126
return buildToolsParent;
129127
}
130-
if (gradle.getParent() == null) {
131-
// See if any of these included builds is the Elasticsearch gradle
132-
for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
133-
if (versionFileExists(includedBuild.getProjectDir())) {
134-
return includedBuild.getProjectDir();
135-
}
128+
return buildToolsParent;
129+
}
130+
if (gradle.getParent() == null) {
131+
// See if any of these included builds is the Elasticsearch gradle
132+
for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
133+
if (versionFileExists(includedBuild.getProjectDir())) {
134+
return includedBuild.getProjectDir();
136135
}
137-
138-
// Otherwise assume this gradle is the root elasticsearch workspace
139-
return gradle.getRootProject().getRootDir();
140-
} else {
141-
// We're an included build, so keep looking
142-
return locateElasticsearchWorkspace(gradle.getParent());
143136
}
137+
138+
// Otherwise assume this gradle is the root elasticsearch workspace
139+
return gradle.getRootProject().getRootDir();
140+
} else {
141+
// We're an included build, so keep looking
142+
return locateElasticsearchWorkspace(gradle.getParent());
144143
}
144+
}
145145

146146
private static boolean versionFileExists(File rootDir) {
147147
return new File(rootDir, "build-tools-internal/version.properties").exists();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public void execute(Task t) {
147147
// don't track these as inputs since they contain absolute paths and break cache relocatability
148148
File gradleUserHome = project.getGradle().getGradleUserHomeDir();
149149
nonInputProperties.systemProperty("gradle.user.home", gradleUserHome);
150+
nonInputProperties.systemProperty("workspace.dir", Util.locateElasticsearchWorkspace(project.getGradle()));
150151
// we use 'temp' relative to CWD since this is per JVM and tests are forbidden from writing to CWD
151152
nonInputProperties.systemProperty("java.io.tmpdir", test.getWorkingDir().toPath().resolve("temp"));
152153

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static boolean isExcludedOs() {
115115
}
116116

117117
private static List<String> getLinuxExclusionList() {
118-
File exclusionsFile = new File(DOCKER_ON_LINUX_EXCLUSIONS_FILE);
118+
File exclusionsFile = new File(System.getProperty("workspace.dir"), DOCKER_ON_LINUX_EXCLUSIONS_FILE);
119119
if (exclusionsFile.exists()) {
120120
try {
121121
return Files.readAllLines(exclusionsFile.toPath())

0 commit comments

Comments
 (0)