use of io.fabric8.maven.docker.assembly.DockerAssemblyConfigurationSource in project docker-maven-plugin by fabric8io.
the class DockerAssemblyConfigurationSourceTest method testOutputDirHasImage.
@Test
public void testOutputDirHasImage() {
String image = "image";
MojoParameters params = buildParameters(".", "src/docker", "output/docker");
DockerAssemblyConfigurationSource source = new DockerAssemblyConfigurationSource(params, new BuildDirs(image, params), assemblyConfig);
assertTrue(containsDir(image, source.getOutputDirectory()));
assertTrue(containsDir(image, source.getWorkingDirectory()));
assertTrue(containsDir(image, source.getTemporaryRootDirectory()));
}
use of io.fabric8.maven.docker.assembly.DockerAssemblyConfigurationSource in project docker-maven-plugin by fabric8io.
the class DockerAssemblyConfigurationSourceTest method testReactorProjects.
@Test
public void testReactorProjects() {
MavenProject reactorProject1 = new MavenProject();
reactorProject1.setFile(new File("../reactor-1"));
MavenProject reactorProject2 = new MavenProject();
reactorProject2.setFile(new File("../reactor-2"));
DockerAssemblyConfigurationSource source = new DockerAssemblyConfigurationSource(new MojoParameters(null, null, null, null, null, null, "/src/docker", "/output/docker", Arrays.asList(new MavenProject[] { reactorProject1, reactorProject2 })), null, null);
assertEquals(2, source.getReactorProjects().size());
}
use of io.fabric8.maven.docker.assembly.DockerAssemblyConfigurationSource 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 io.fabric8.maven.docker.assembly.DockerAssemblyConfigurationSource 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 io.fabric8.maven.docker.assembly.DockerAssemblyConfigurationSource in project docker-maven-plugin by fabric8io.
the class DockerFileUtil method createInterpolator.
/**
* Create an interpolator for the given maven parameters and filter configuration.
*
* @param params The maven parameters.
* @param filter The filter configuration.
* @return An interpolator for replacing maven properties.
*/
public static FixedStringSearchInterpolator createInterpolator(MojoParameters params, String filter) {
String[] delimiters = extractDelimiters(filter);
if (delimiters == null) {
// Don't interpolate anything
return FixedStringSearchInterpolator.create();
}
DockerAssemblyConfigurationSource configSource = new DockerAssemblyConfigurationSource(params, null, null);
// Patterned after org.apache.maven.plugin.assembly.interpolation.AssemblyExpressionEvaluator
return AssemblyInterpolator.fullInterpolator(params.getProject(), DefaultAssemblyReader.createProjectInterpolator(params.getProject()), configSource).withExpressionMarkers(delimiters[0], delimiters[1]);
}
Aggregations