Skip to content

Commit

Permalink
BWC Build: Read CI properties to determine java version (#34295)
Browse files Browse the repository at this point in the history
  • Loading branch information
alpar-t authored Oct 5, 2018
1 parent f420eeb commit 76310eb
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,30 @@ subprojects {

task buildBwcVersion(type: Exec) {
dependsOn checkoutBwcBranch, writeBuildMetadata
// send RUNTIME_JAVA_HOME so the build doesn't fails on newer version the branch doesn't know about
environment('RUNTIME_JAVA_HOME', getJavaHome(it, rootProject.ext.minimumRuntimeVersion.getMajorVersion() as int))
workingDir = checkoutDir
// we are building branches that are officially built with JDK 8, push JAVA8_HOME to JAVA_HOME for these builds
if (["5.6", "6.0", "6.1"].contains(bwcBranch)) {
environment('JAVA_HOME', getJavaHome(it, 8))
} else if ("6.2".equals(bwcBranch)) {
environment('JAVA_HOME', getJavaHome(it, 9))
} else if (["6.3", "6.4"].contains(bwcBranch)) {
environment('JAVA_HOME', getJavaHome(it, 10))
} else if (["6.x"].contains(bwcBranch)) {
environment('JAVA_HOME', getJavaHome(it, 11))
} else {
environment('JAVA_HOME', project.compilerJavaHome)
doFirst {
// Execution time so that the checkouts are available
List<String> lines = file("$checkoutDir/.ci/java-versions.properties").readLines()
environment(
'JAVA_HOME',
getJavaHome(it, Integer.parseInt(
lines
.findAll({ it.startsWith("ES_BUILD_JAVA=java") })
.collect({ it.replace("ES_BUILD_JAVA=java", "").trim() })
.join("!!")
))
)
environment(
'RUNTIME_JAVA_HOME',
getJavaHome(it, Integer.parseInt(
lines
.findAll({ it.startsWith("ES_RUNTIME_JAVA=java") })
.collect({ it.replace("ES_RUNTIME_JAVA=java", "").trim() })
.join("!!")
))
)
}

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
executable 'cmd'
args '/C', 'call', new File(checkoutDir, 'gradlew').toString()
Expand Down Expand Up @@ -237,4 +246,4 @@ class IndentingOutputStream extends OutputStream {
}
}
}
}
}

0 comments on commit 76310eb

Please sign in to comment.