Skip to content

Commit

Permalink
Handle requiring versioned java home during execution (#37599)
Browse files Browse the repository at this point in the history
Currently bwc builds require different java home environment variables
depending on the version of elasticsearch being built. The java home
version checks are run at the end of gradle configuration, when the task
graph is ready. However, we do not know which versions are needed for
bwc builds until execution time, when we have finished checking out the
version of elasticsearch to be built. This commit accounts for late java
home checks, checking immediately instead of delaying the check.

closes #37586
  • Loading branch information
rjernst committed Jan 21, 2019
1 parent ce60585 commit 79e9ac4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,16 @@ class BuildPlugin implements Plugin<Project> {
if (messages.isEmpty() == false) {
throw new GradleException(messages.join('\n'))
}
rootProject.rootProject.ext.requiredJavaVersions = null // reset to null to indicate the pre-execution checks have executed
}
} else if (rootProject.rootProject.requiredJavaVersions == null) {
// check directly if the version is present since we are already executing
if (rootProject.javaVersions.get(version) == null) {
throw new GradleException("JAVA${version}_HOME required to run task:\n${task}")
}
} else {
rootProject.requiredJavaVersions.get(version).add(task)
}
rootProject.requiredJavaVersions.get(version).add(task)
}

/** A convenience method for getting java home for a version of java and requiring that version for the given task to execute */
Expand Down

0 comments on commit 79e9ac4

Please sign in to comment.