use of org.apache.maven.plugin.assembly.model.Assembly 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);
}
}
use of org.apache.maven.plugin.assembly.model.Assembly in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManager method getAssemblyFiles.
/**
* Extract all files with a tracking archiver. These can be used to track changes in the filesystem and triggering
* a rebuild of the image if needed ('docker:watch')
*/
public AssemblyFiles getAssemblyFiles(String name, BuildImageConfiguration buildConfig, MojoParameters mojoParams, Logger log) throws InvalidAssemblerConfigurationException, ArchiveCreationException, AssemblyFormattingException, MojoExecutionException {
BuildDirs buildDirs = createBuildDirs(name, mojoParams);
AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
String assemblyName = assemblyConfig.getName();
DockerAssemblyConfigurationSource source = new DockerAssemblyConfigurationSource(mojoParams, buildDirs, assemblyConfig);
Assembly assembly = getAssemblyConfig(assemblyConfig, source);
synchronized (trackArchiver) {
MappingTrackArchiver ta = (MappingTrackArchiver) trackArchiver;
ta.init(log, assemblyName);
assembly.setId("tracker");
assemblyArchiver.createArchive(assembly, assemblyName, "track", source, false);
return ta.getAssemblyFiles(mojoParams.getSession());
}
}
use of org.apache.maven.plugin.assembly.model.Assembly in project fabric8-maven-plugin by fabric8io.
the class JavaExecGenerator method addAssembly.
protected void addAssembly(AssemblyConfiguration.Builder builder) throws MojoExecutionException {
String assemblyRef = getConfig(Config.assemblyRef);
if (assemblyRef != null) {
builder.descriptorRef(assemblyRef);
} else {
if (isFatJar()) {
FatJarDetector.Result fatJar = detectFatJar();
Assembly assembly = new Assembly();
MavenProject project = getProject();
if (fatJar == null) {
DependencySet dependencySet = new DependencySet();
dependencySet.addInclude(project.getGroupId() + ":" + project.getArtifactId());
assembly.addDependencySet(dependencySet);
} else {
FileSet fileSet = new FileSet();
File buildDir = new File(project.getBuild().getDirectory());
fileSet.setDirectory(toRelativePath(buildDir, project.getBasedir()));
fileSet.addInclude(toRelativePath(fatJar.getArchiveFile(), buildDir));
fileSet.setOutputDirectory(".");
assembly.addFileSet(fileSet);
}
assembly.addFileSet(createFileSet("src/main/fabric8-includes/bin", "bin", "0755", "0755"));
assembly.addFileSet(createFileSet("src/main/fabric8-includes", ".", "0644", "0755"));
builder.assemblyDef(assembly);
} else {
builder.descriptorRef("artifact-with-dependencies");
}
}
;
}
Aggregations