Source:
<code>public void buildImage(ImageConfiguration imageConfig, MojoParameters params, boolean noCache, Map<String, String> buildArgs) throws DockerAccessException, MojoExecutionException { String imageName = imageConfig.getName(); ImageName.validate(imageName); BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration(); String oldImageId = null; CleanupMode cleanupMode = buildConfig.cleanupMode(); if (cleanupMode.isRemove()) { oldImageId = queryService.getImageId(imageName); } long time = System.currentTimeMillis(); File dockerArchive = archiveService.createArchive(imageName, buildConfig, params, log); log.info("%s: Created %s in %s", dockerArchive.getName(), imageConfig.getDescription(), EnvUtil.formatDurationTill(time)); Map<String, String> mergedBuildMap = prepareBuildArgs(buildArgs, buildConfig); String newImageId = doBuildImage(imageName, dockerArchive, getDockerfileName(buildConfig), cleanupMode.isRemove(), <START> noCache, mergedBuildMap, buildConfig.getBuildOptions()); <END> log.info("%s: Built image %s",imageConfig.getDescription(), newImageId); if (oldImageId != null && !oldImageId.equals(newImageId)) { try { docker.removeImage(oldImageId, true); log.info("%s: Removed old image %s", imageConfig.getDescription(), oldImageId); } catch (DockerAccessException exp) { if (cleanupMode == CleanupMode.TRY_TO_REMOVE) { log.warn("%s: %s (old image)%s", imageConfig.getDescription(), exp.getMessage(), (exp.getCause() != null ? " [" + exp.getCause().getMessage() + "]" : "")); } else { throw exp; } } } }</code><technical_language>argument lists lengthy now, I refactored a BuildOptions argument object. nicer, merge options a single place</technical_language>

Target:
public void buildImage(ImageConfiguration imageConfig, MojoParameters params, boolean noCache, Map<String, String> buildArgs) throws DockerAccessException, MojoExecutionException { String imageName = imageConfig.getName(); ImageName.validate(imageName); BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration(); String oldImageId = null; CleanupMode cleanupMode = buildConfig.cleanupMode(); if (cleanupMode.isRemove()) { oldImageId = queryService.getImageId(imageName); } long time = System.currentTimeMillis(); if (buildConfig.getDockerArchive() != null) { docker.loadImage(imageName, buildConfig.getAbsoluteDockerTarPath(params)); log.info("%s: Loaded tarball in %s", buildConfig.getDockerArchive(), EnvUtil.formatDurationTill(time)); return; } File dockerArchive = archiveService.createArchive(imageName, buildConfig, params, log); log.info("%s: Created %s in %s", dockerArchive.getName(), imageConfig.getDescription(), EnvUtil.formatDurationTill(time)); Map<String, String> mergedBuildMap = prepareBuildArgs(buildArgs, buildConfig); BuildOptions opts = new BuildOptions(buildConfig.getBuildOptions()) .dockerfile(getDockerfileName(buildConfig)) .forceRemove(cleanupMode.isRemove()) .noCache(noCache) .buildArgs(mergedBuildMap); String newImageId = doBuildImage(imageName, dockerArchive, opts); log.info("%s: Built image %s",imageConfig.getDescription(), newImageId); if (oldImageId != null && !oldImageId.equals(newImageId)) { try { docker.removeImage(oldImageId, true); log.info("%s: Removed old image %s", imageConfig.getDescription(), oldImageId); } catch (DockerAccessException exp) { if (cleanupMode == CleanupMode.TRY_TO_REMOVE) { log.warn("%s: %s (old image)%s", imageConfig.getDescription(), exp.getMessage(), (exp.getCause() != null ? " [" + exp.getCause().getMessage() + "]" : "")); } else { throw exp; } } } }