use of io.fabric8.maven.docker.config.AssemblyMode in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManager method createBuildArchiver.
private TarArchiver createBuildArchiver(File outputDir, File archive, List<AssemblyConfiguration> assemblyConfigs) throws NoSuchArchiverException {
TarArchiver archiver = (TarArchiver) archiverManager.getArchiver(TAR_ARCHIVER_TYPE);
archiver.setLongfile(TarLongFileMode.posix);
boolean needsDefaultFileSet = assemblyConfigs.isEmpty();
for (AssemblyConfiguration assemblyConfig : assemblyConfigs) {
AssemblyMode mode = assemblyConfig != null ? assemblyConfig.getMode() : null;
if (mode != null && mode.isArchive()) {
DefaultArchivedFileSet archiveSet = DefaultArchivedFileSet.archivedFileSet(new File(outputDir, assemblyConfig.getName() + "." + mode.getExtension()));
archiveSet.setPrefix(assemblyConfig.getName() + "/");
archiveSet.setIncludingEmptyDirectories(true);
archiveSet.setUsingDefaultExcludes(false);
archiver.addArchivedFileSet(archiveSet);
} else {
needsDefaultFileSet = true;
}
}
if (needsDefaultFileSet) {
DefaultFileSet fileSet = DefaultFileSet.fileSet(outputDir);
fileSet.setUsingDefaultExcludes(false);
archiver.addFileSet(fileSet);
}
archiver.setDestFile(archive);
return archiver;
}
use of io.fabric8.maven.docker.config.AssemblyMode in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManager method createBuildArchiver.
private TarArchiver createBuildArchiver(File outputDir, File archive, AssemblyConfiguration assemblyConfig) throws NoSuchArchiverException {
TarArchiver archiver = (TarArchiver) archiverManager.getArchiver("tar");
archiver.setLongfile(TarLongFileMode.posix);
AssemblyMode mode = assemblyConfig != null ? assemblyConfig.getMode() : null;
if (mode != null && mode.isArchive()) {
DefaultArchivedFileSet archiveSet = DefaultArchivedFileSet.archivedFileSet(new File(outputDir, assemblyConfig.getName() + "." + mode.getExtension()));
archiveSet.setPrefix(assemblyConfig.getName() + "/");
archiveSet.setIncludingEmptyDirectories(true);
archiveSet.setUsingDefaultExcludes(false);
archiver.addArchivedFileSet(archiveSet);
} else {
DefaultFileSet fileSet = DefaultFileSet.fileSet(outputDir);
fileSet.setUsingDefaultExcludes(false);
archiver.addFileSet(fileSet);
}
archiver.setDestFile(archive);
return archiver;
}
use of io.fabric8.maven.docker.config.AssemblyMode 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, null);
} 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);
}
}
Aggregations