@Override
    protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
        MojoParameters params = createMojoParameters();
        List<ImageConfiguration> imageConfigs = new ArrayList<>();
        for (ImageConfiguration imageConfig : getResolvedImages()) {
            BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
            if (buildConfig != null) {
                if (buildConfig.skip()) {
                    log.info("%s: Skipped creating source",imageConfig.getDescription());
                } else {
                    imageConfigs.add(imageConfig);
                }
            }
        }
        if (sourceMode == BuildImageSelectMode.first && !imageConfigs.isEmpty()) {
            ImageConfiguration imageConfig = imageConfigs.get(0);
            File dockerTar = hub.getArchiveService().createDockerBuildArchive(imageConfig, params);
            projectHelper.attachArtifact(project, getArchiveType(imageConfig),
                                         getClassifier(null), dockerTar);
        } else {
            for (ImageConfiguration imageConfig : imageConfigs) {
                File dockerTar = hub.getArchiveService().createDockerBuildArchive(imageConfig, params);
                String alias = imageConfig.getAlias();
                if (alias == null) {
                    throw new IllegalArgumentException(
                        "Image " + imageConfig.getDescription() + " must have an 'alias' configured to be " +
                        "used as a classifier for attaching a docker build tar as source to the maven build");
                }
                projectHelper.attachArtifact(project, getArchiveType(imageConfig), getClassifier(alias), dockerTar);
            }
        }
    }
Mode how to attach the source artifact:

<ul>
    <li><strong>first</strong> : The first image with build configuration</li>
    <li><strong>all</strong> : All images with build configuration. Each image must have an alias
       configured which is use as part of the classifier.
    </li>
</ul>
src/main/java/io/fabric8/maven/docker/SourceMojo.java