Skip to content

Commit 4a0db31

Browse files
committed
BWC Build: Read CI properties to determine java version (#34295)
1 parent ede6438 commit 4a0db31

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

distribution/bwc/build.gradle

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,30 @@ subprojects {
149149

150150
task buildBwcVersion(type: Exec) {
151151
dependsOn checkoutBwcBranch, writeBuildMetadata
152-
// send RUNTIME_JAVA_HOME so the build doesn't fails on newer version the branch doesn't know about
153-
environment('RUNTIME_JAVA_HOME', getJavaHome(it, rootProject.ext.minimumRuntimeVersion.getMajorVersion() as int))
154152
workingDir = checkoutDir
155-
// we are building branches that are officially built with JDK 8, push JAVA8_HOME to JAVA_HOME for these builds
156-
if (["5.6", "6.0", "6.1"].contains(bwcBranch)) {
157-
environment('JAVA_HOME', getJavaHome(it, 8))
158-
} else if ("6.2".equals(bwcBranch)) {
159-
environment('JAVA_HOME', getJavaHome(it, 9))
160-
} else if (["6.3", "6.4"].contains(bwcBranch)) {
161-
environment('JAVA_HOME', getJavaHome(it, 10))
162-
} else if (["6.x"].contains(bwcBranch)) {
163-
environment('JAVA_HOME', getJavaHome(it, 11))
164-
} else {
165-
environment('JAVA_HOME', project.compilerJavaHome)
153+
doFirst {
154+
// Execution time so that the checkouts are available
155+
List<String> lines = file("$checkoutDir/.ci/java-versions.properties").readLines()
156+
environment(
157+
'JAVA_HOME',
158+
getJavaHome(it, Integer.parseInt(
159+
lines
160+
.findAll({ it.startsWith("ES_BUILD_JAVA=java") })
161+
.collect({ it.replace("ES_BUILD_JAVA=java", "").trim() })
162+
.join("!!")
163+
))
164+
)
165+
environment(
166+
'RUNTIME_JAVA_HOME',
167+
getJavaHome(it, Integer.parseInt(
168+
lines
169+
.findAll({ it.startsWith("ES_RUNTIME_JAVA=java") })
170+
.collect({ it.replace("ES_RUNTIME_JAVA=java", "").trim() })
171+
.join("!!")
172+
))
173+
)
166174
}
175+
167176
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
168177
executable 'cmd'
169178
args '/C', 'call', new File(checkoutDir, 'gradlew').toString()
@@ -237,4 +246,4 @@ class IndentingOutputStream extends OutputStream {
237246
}
238247
}
239248
}
240-
}
249+
}

0 commit comments

Comments
 (0)