Build Docker images if the binary exists (#36459)

This commit changes the Docker assemble tasks so that they attempt to
build Docker if the Docker binaries exist, of if build.docker is set to
true. If the Docker binaries do not exist, or if build.docker is set to
false, then no attempt is made to build the Docker images.
This commit is contained in:
Jason Tedor 2018-12-10 18:36:55 -05:00 committed by GitHub
parent de06769677
commit b030125e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -245,9 +245,16 @@ class BuildPlugin implements Plugin<Project> {
*
* If either of these fail, we fail the build.
*/
// check if the Docker binary exists and record its path
final List<String> maybeDockerBinaries = ['/usr/bin/docker', '/usr/local/bin/docker']
final String dockerBinary = maybeDockerBinaries.find { it -> new File(it).exists() }
final boolean buildDocker
final String buildDockerProperty = System.getProperty("build.docker")
if (buildDockerProperty == null || buildDockerProperty == "true") {
if (buildDockerProperty == null) {
buildDocker = dockerBinary != null
} else if (buildDockerProperty == "true") {
buildDocker = true
} else if (buildDockerProperty == "false") {
buildDocker = false
@ -258,10 +265,6 @@ class BuildPlugin implements Plugin<Project> {
rootProject.rootProject.ext.buildDocker = buildDocker
rootProject.rootProject.ext.requiresDocker = []
rootProject.gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
// check if the Docker binary exists and record its path
final List<String> maybeDockerBinaries = ['/usr/bin/docker', '/usr/local/bin/docker']
final String dockerBinary = maybeDockerBinaries.find { it -> new File(it).exists() }
int exitCode
String dockerErrorOutput
if (dockerBinary == null) {