Skip to content

Commit e48f038

Browse files
committed
Disable toolchain autodetection for now
1 parent 2b7f0a8 commit e48f038

File tree

6 files changed

+91
-27
lines changed

6 files changed

+91
-27
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
import java.util.Locale;
5858
import java.util.Map;
5959
import java.util.Random;
60-
import java.util.Set;
61-
import java.util.function.Predicate;
6260
import java.util.regex.Matcher;
6361
import java.util.regex.Pattern;
6462
import java.util.stream.Collectors;
@@ -68,12 +66,6 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
6866
private static final Logger LOGGER = Logging.getLogger(GlobalBuildInfoPlugin.class);
6967
private static final String DEFAULT_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/elasticsearch/Version.java";
7068
private static Integer _defaultParallel = null;
71-
private static Set<File> JAVA_HOME_ENVS = System.getenv()
72-
.entrySet()
73-
.stream()
74-
.filter(entry -> entry.getKey().matches(".*JAVA.*_HOME"))
75-
.map(entry -> new File(entry.getValue()))
76-
.collect(Collectors.toSet());
7769

7870
private final SharedJavaInstallationRegistry javaInstallationRegistry;
7971
private JvmMetadataDetector metadataDetector;
@@ -195,7 +187,7 @@ private JavaVersion determineJavaVersion(String description, File javaHome, Java
195187

196188
private InstallationLocation getJavaInstallation(File javaHome) {
197189
System.out.println("javaHome = " + javaHome);
198-
return filteredInstallationLocationStream().map(i -> {
190+
return javaInstallationRegistry.listInstallations().stream().map(i -> {
199191
System.out.println("installation = " + i.getDisplayName());
200192
return i;
201193
}).filter(installationLocation -> isSameFile(javaHome, installationLocation)).findFirst().get();
@@ -214,27 +206,14 @@ private boolean isSameFile(File javaHome, InstallationLocation installationLocat
214206
* To make transition more reliable we only take env var provided installations into account for now
215207
*/
216208
private List<JavaHome> getAvailableJavaVersions() {
217-
return filteredInstallationLocationStream().map(installationLocation -> {
209+
return javaInstallationRegistry.listInstallations().stream().map(installationLocation -> {
218210
File installationDir = installationLocation.getLocation();
219211
JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationDir);
220212
int actualVersion = Integer.parseInt(metadata.getLanguageVersion().getMajorVersion());
221213
return JavaHome.of(actualVersion, providers.provider(() -> installationDir));
222214
}).collect(Collectors.toList());
223215
}
224216

225-
private Stream<InstallationLocation> filteredInstallationLocationStream() {
226-
// We cannot filter by InstallationLocation#source = env as it is not reliable
227-
// as only the 1st found source type is listed. E.g. jdk detected by sdkman detection AND
228-
// ENV variable does only list one source in a non deterministic way.
229-
return javaInstallationRegistry.listInstallations()
230-
.stream()
231-
.filter(
232-
installation -> installation.getSource().contains("Current JVM")
233-
|| installation.getSource().contains("java_home")
234-
|| JAVA_HOME_ENVS.stream().anyMatch(envHome -> isSameFile(envHome, installation))
235-
);
236-
}
237-
238217
private static String getTestSeed() {
239218
String testSeedProperty = System.getProperty("tests.seed");
240219
final String testSeed;
@@ -461,10 +440,6 @@ private static String readFirstLine(final Path path) throws IOException {
461440
return firstLine;
462441
}
463442

464-
private static Predicate<InstallationLocation> javaInstallationFilter = installation -> installation.getSource().contains("Current JVM")
465-
|| installation.getSource().contains("java_home")
466-
|| installation.getSource().contains("environment variable");
467-
468443
public static class GitInfo {
469444
private final String revision;
470445
private final String origin;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to Elasticsearch under one or more contributor
3+
# license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright
5+
# ownership. Elasticsearch licenses this file to you under
6+
# the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# java homes resolved by environment variables
21+
org.gradle.java.installations.auto-detect=false
22+
org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to Elasticsearch under one or more contributor
3+
# license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright
5+
# ownership. Elasticsearch licenses this file to you under
6+
# the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# java homes resolved by environment variables
21+
org.gradle.java.installations.auto-detect=false
22+
org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to Elasticsearch under one or more contributor
3+
# license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright
5+
# ownership. Elasticsearch licenses this file to you under
6+
# the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# java homes resolved by environment variables
21+
org.gradle.java.installations.auto-detect=false
22+
org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to Elasticsearch under one or more contributor
3+
# license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright
5+
# ownership. Elasticsearch licenses this file to you under
6+
# the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# java homes resolved by environment variables
21+
org.gradle.java.installations.auto-detect=false
22+
org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ systemProp.org.gradle.warning.mode=fail
1414
systemProp.jdk.tls.client.protocols=TLSv1.2
1515

1616
# java homes resolved by environment variables
17+
org.gradle.java.installations.auto-detect=false
1718
org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

0 commit comments

Comments
 (0)