|
30 | 30 | import org.elasticsearch.gradle.Version; |
31 | 31 | import org.elasticsearch.gradle.VersionProperties; |
32 | 32 | import org.elasticsearch.gradle.http.WaitForHttpResource; |
| 33 | +import org.elasticsearch.gradle.info.BuildParams; |
33 | 34 | import org.gradle.api.Action; |
34 | 35 | import org.gradle.api.Named; |
35 | 36 | import org.gradle.api.NamedDomainObjectContainer; |
@@ -145,7 +146,6 @@ public class ElasticsearchNode implements TestClusterConfiguration { |
145 | 146 | private int currentDistro = 0; |
146 | 147 | private TestDistribution testDistribution; |
147 | 148 | private List<ElasticsearchDistribution> distributions = new ArrayList<>(); |
148 | | - private File javaHome; |
149 | 149 | private volatile Process esProcess; |
150 | 150 | private Function<String, String> nameCustomization = Function.identity(); |
151 | 151 | private boolean isWorkingDirConfigured = false; |
@@ -373,21 +373,6 @@ public void freeze() { |
373 | 373 | configurationFrozen.set(true); |
374 | 374 | } |
375 | 375 |
|
376 | | - @Override |
377 | | - public void setJavaHome(File javaHome) { |
378 | | - requireNonNull(javaHome, "null javaHome passed when configuring test cluster `" + this + "`"); |
379 | | - checkFrozen(); |
380 | | - if (javaHome.exists() == false) { |
381 | | - throw new TestClustersException("java home for `" + this + "` does not exists: `" + javaHome + "`"); |
382 | | - } |
383 | | - this.javaHome = javaHome; |
384 | | - } |
385 | | - |
386 | | - @Internal |
387 | | - public File getJavaHome() { |
388 | | - return javaHome; |
389 | | - } |
390 | | - |
391 | 376 | /** |
392 | 377 | * Returns a stream of lines in the generated logs similar to Files.lines |
393 | 378 | * |
@@ -665,8 +650,9 @@ private void runElasticsearchBinScript(String tool, CharSequence... args) { |
665 | 650 |
|
666 | 651 | private Map<String, String> getESEnvironment() { |
667 | 652 | Map<String, String> defaultEnv = new HashMap<>(); |
668 | | - if (getJavaHome() != null) { |
669 | | - defaultEnv.put("JAVA_HOME", getJavaHome().getAbsolutePath()); |
| 653 | + // If we are testing the current version of Elasticsearch, use the configured runtime Java, otherwise use the bundled JDK |
| 654 | + if (getTestDistribution() == TestDistribution.INTEG_TEST || getVersion().toString().equals(VersionProperties.getElasticsearch())) { |
| 655 | + defaultEnv.put("JAVA_HOME", BuildParams.getRuntimeJavaHome().getAbsolutePath()); |
670 | 656 | } |
671 | 657 | defaultEnv.put("ES_PATH_CONF", configFile.getParent().toString()); |
672 | 658 | String systemPropertiesString = ""; |
|
0 commit comments