Lazy configure build tasks that require older JDKs (elastic/x-pack-elasticsearch#4376)

Some build tasks require older JDKs. For example, the BWC build tasks
for older versions of Elasticsearch require older JDKs. It is onerous to
require these be configured when merely compiling Elasticsearch, the
requirement that they be strictly set to appropriate values should only
be enforced if these tasks are going to be executed. To address this, we
lazy configure these tasks.

Original commit: elastic/x-pack-elasticsearch@804a11c243
This commit is contained in:
Jason Tedor 2018-04-14 15:45:01 -04:00 committed by GitHub
parent 614d28cee7
commit 0e89f07c3f
1 changed files with 5 additions and 11 deletions

View File

@ -1,10 +1,10 @@
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
import org.elasticsearch.gradle.Version
import java.util.regex.Matcher
import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.LoggedExec
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.test.NodeInfo import org.elasticsearch.gradle.test.NodeInfo
import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
/** /**
* Subdirectories of this project are dummy projects which does a local * Subdirectories of this project are dummy projects which does a local
* checkout of the appropriate version's branch, and builds a snapshot. This * checkout of the appropriate version's branch, and builds a snapshot. This
@ -194,15 +194,9 @@ subprojects {
workingDir = xpackCheckoutDir workingDir = xpackCheckoutDir
if (["5.6", "6.0", "6.1"].contains(bwcBranch)) { 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 // 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) { environment('JAVA_HOME', "${-> getJavaHome(project, 8, "JAVA8_HOME is required to build BWC versions for BWC branch [" + bwcBranch + "]")}")
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)) { } else if ("6.2".equals(bwcBranch)) {
if (project.javaVersions.get(9) == null) { environment('JAVA_HOME', "${-> getJavaHome(project, 9, "JAVA9_HOME is required to build BWC versions for BWC branch [" + bwcBranch + "]")}")
throw new GradleException("JAVA9_HOME is required to build BWC versions for BWC branch [" + bwcBranch + "]")
}
environment('JAVA_HOME', project.javaVersions.get(9))
} else { } else {
environment('JAVA_HOME', project.compilerJavaHome) environment('JAVA_HOME', project.compilerJavaHome)
} }