Use proper Java version for BWC builds (elastic/x-pack-elasticsearch#4365)
This commit sets the BWC builds to use the version of the JDK that is
appropriate for the indvidual version of Elasticsearch under test.
Original commit: elastic/x-pack-elasticsearch@2219b3d4fcaa2e997893affa24d51816bbb9ddc5
@@ -192,12 +192,19 @@ subprojects {
task buildBwcVersion(type: Exec) {
dependsOn checkoutXPackBwcBranch, checkoutElasticsearchBwcBranch, writeElasticsearchBuildMetadata, writeXPackBuildMetadata
workingDir = xpackCheckoutDir
- if (project.rootProject.ext.runtimeJavaVersion == JavaVersion.VERSION_1_8 && ["5.6", "6.0", "6.1"].contains(bwcBranch)) {
- /*
- * If runtime Java home is set to JDK 8 and we are building branches that are officially built with JDK 8, push this to JAVA_HOME for
- * these builds.
- */
- environment('JAVA_HOME', System.getenv('RUNTIME_JAVA_HOME'))
+ if (["5.6", "6.0", "6.1"].contains(bwcBranch)) {
+ // we are building branches that are officially built with JDK 8, push JAVA8_HOME to JAVA_HOME for these builds
+ if (project.javaVersions.get(8) == null) {
+ throw new GradleException("JAVA8_HOME is required to build BWC versions for BWC branch [" + bwcBranch + "]")
+ }
+ environment('JAVA_HOME', project.javaVersions.get(8))
+ } else if ("6.2".equals(bwcBranch)) {
+ if (project.javaVersions.get(9) == null) {
+ throw new GradleException("JAVA9_HOME is required to build BWC versions for BWC branch [" + bwcBranch + "]")
+ }
+ environment('JAVA_HOME', project.javaVersions.get(9))
+ } else {
+ environment('JAVA_HOME', project.compilerJavaHome)
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
executable 'cmd'
