@@ -293,18 +293,7 @@ class BuildPlugin implements Plugin<Project> {
293293 it. standardOutput = dockerVersionOutput
294294 })
295295 final String dockerVersion = dockerVersionOutput. toString(). trim()
296- final Matcher matcher = dockerVersion =~ / Docker version (\d +\.\d +)\.\d +(?:-ce)?, build [0-9a-f]{7}/
297- assert matcher. matches() : dockerVersion
298- final dockerMajorMinorVersion = matcher. group(1 )
299- final String [] majorMinor = dockerMajorMinorVersion. split(" \\ ." )
300- if (Integer . parseInt(majorMinor[0 ]) < 17
301- || (Integer . parseInt(majorMinor[0 ]) == 17 && Integer . parseInt(majorMinor[1 ]) < 5 )) {
302- final String message = String . format(
303- Locale . ROOT ,
304- " building Docker images requires Docker version 17.05+ due to use of multi-stage builds yet was [%s]" ,
305- dockerVersion)
306- throwDockerRequiredException(message)
307- }
296+ checkDockerVersionRecent(dockerVersion)
308297
309298 final ByteArrayOutputStream dockerImagesErrorOutput = new ByteArrayOutputStream ()
310299 // the Docker binary executes, check that we can execute a privileged command
@@ -339,6 +328,21 @@ class BuildPlugin implements Plugin<Project> {
339328 }
340329 }
341330
331+ protected static void checkDockerVersionRecent (String dockerVersion ) {
332+ final Matcher matcher = dockerVersion =~ / Docker version (\d +\.\d +)\.\d +(?:-ce)?, build [0-9a-f]{7,40}/
333+ assert matcher. matches(): dockerVersion
334+ final dockerMajorMinorVersion = matcher. group(1 )
335+ final String [] majorMinor = dockerMajorMinorVersion. split(" \\ ." )
336+ if (Integer . parseInt(majorMinor[0 ]) < 17
337+ || (Integer . parseInt(majorMinor[0 ]) == 17 && Integer . parseInt(majorMinor[1 ]) < 5 )) {
338+ final String message = String . format(
339+ Locale . ROOT ,
340+ " building Docker images requires Docker version 17.05+ due to use of multi-stage builds yet was [%s]" ,
341+ dockerVersion)
342+ throwDockerRequiredException(message)
343+ }
344+ }
345+
342346 private static void throwDockerRequiredException (final String message ) {
343347 throw new GradleException (
344348 message + " \n you can address this by attending to the reported issue, "
0 commit comments