Search in sources :

Example 1 with InvalidAssemblerConfigurationException

use of org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManager method createAssemblyArchive.

private void createAssemblyArchive(AssemblyConfiguration assemblyConfig, MojoParameters params, BuildDirs buildDirs) throws MojoExecutionException {
    DockerAssemblyConfigurationSource source = new DockerAssemblyConfigurationSource(params, buildDirs, assemblyConfig);
    Assembly assembly = getAssemblyConfig(assemblyConfig, source);
    AssemblyMode buildMode = assemblyConfig.getMode();
    File originalArtifactFile = null;
    try {
        originalArtifactFile = ensureThatArtifactFileIsSet(params.getProject());
        assembly.setId("docker");
        assemblyArchiver.createArchive(assembly, assemblyConfig.getName(), buildMode.getExtension(), source, false);
    } catch (ArchiveCreationException | AssemblyFormattingException e) {
        String error = "Failed to create assembly for docker image " + " (with mode '" + buildMode + "'): " + e.getMessage() + ".";
        if (params.getProject().getArtifact().getFile() == null) {
            error += " If you include the build artifact please ensure that you have " + "built the artifact before with 'mvn package' (should be available in the target/ dir). " + "Please see the documentation (section \"Assembly\") for more information.";
        }
        throw new MojoExecutionException(error, e);
    } catch (InvalidAssemblerConfigurationException e) {
        throw new MojoExecutionException(assembly, "Assembly is incorrectly configured: " + assembly.getId(), "Assembly: " + assembly.getId() + " is not configured correctly: " + e.getMessage());
    } finally {
        setArtifactFile(params.getProject(), originalArtifactFile);
    }
}
Also used : AssemblyFormattingException(org.apache.maven.plugin.assembly.format.AssemblyFormattingException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiveCreationException(org.apache.maven.plugin.assembly.archive.ArchiveCreationException) AssemblyMode(io.fabric8.maven.docker.config.AssemblyMode) InvalidAssemblerConfigurationException(org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException) File(java.io.File) Assembly(org.apache.maven.plugin.assembly.model.Assembly)

Aggregations

AssemblyMode (io.fabric8.maven.docker.config.AssemblyMode)1 File (java.io.File)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 InvalidAssemblerConfigurationException (org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException)1 ArchiveCreationException (org.apache.maven.plugin.assembly.archive.ArchiveCreationException)1 AssemblyFormattingException (org.apache.maven.plugin.assembly.format.AssemblyFormattingException)1 Assembly (org.apache.maven.plugin.assembly.model.Assembly)1