use of org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testIncludeSiteInAssembly_ShouldFailIfSiteDirectoryNonExistent.
public void testIncludeSiteInAssembly_ShouldFailIfSiteDirectoryNonExistent() throws IOException {
final File siteDir = File.createTempFile("assembly-reader.", ".test");
siteDir.delete();
expect(configSource.getSiteDirectory()).andReturn(siteDir).anyTimes();
final Assembly assembly = new Assembly();
mockManager.replayAll();
try {
new DefaultAssemblyReader().includeSiteInAssembly(assembly, configSource);
fail("Should fail when site directory is non-existent.");
} catch (final InvalidAssemblerConfigurationException e) {
// this should happen.
}
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException in project maven-plugins by apache.
the class FilterUtilsTest method testFilterArtifacts_ShouldThrowExceptionUsingStrictModeWithUnmatchedInclude.
public void testFilterArtifacts_ShouldThrowExceptionUsingStrictModeWithUnmatchedInclude() {
final Artifact artifact = mockManager.createMock(Artifact.class);
expect(artifact.getGroupId()).andReturn("group").atLeastOnce();
expect(artifact.getArtifactId()).andReturn("artifact").atLeastOnce();
expect(artifact.getId()).andReturn("group:artifact:type:version").atLeastOnce();
expect(artifact.getDependencyConflictId()).andReturn("group:artifact:type").atLeastOnce();
final List<String> includes = new ArrayList<String>();
includes.add("other.group:other-artifact:type:version");
final List<String> excludes = Collections.emptyList();
final Set<Artifact> artifacts = new HashSet<Artifact>();
artifacts.add(artifact);
mockManager.replayAll();
try {
FilterUtils.filterArtifacts(artifacts, includes, excludes, true, false, logger);
fail("Should fail because of unmatched include.");
} catch (final InvalidAssemblerConfigurationException e) {
// expected.
}
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method selectContainerDescriptorHandlers.
// CHECKSTYLE_OFF: LineLength
private List<ContainerDescriptorHandler> selectContainerDescriptorHandlers(List<ContainerDescriptorHandlerConfig> requestedContainerDescriptorHandlers, final AssemblerConfigurationSource configSource) throws InvalidAssemblerConfigurationException // CHECKSTYLE_ON: LineLength
{
getLogger().debug("All known ContainerDescriptorHandler components: " + (containerDescriptorHandlers == null ? "none; map is null." : "" + containerDescriptorHandlers.keySet()));
if (requestedContainerDescriptorHandlers == null) {
requestedContainerDescriptorHandlers = new ArrayList<ContainerDescriptorHandlerConfig>();
}
final List<ContainerDescriptorHandler> handlers = new ArrayList<ContainerDescriptorHandler>();
final List<String> hints = new ArrayList<String>();
if (!requestedContainerDescriptorHandlers.isEmpty()) {
for (final ContainerDescriptorHandlerConfig config : requestedContainerDescriptorHandlers) {
final String hint = config.getHandlerName();
final ContainerDescriptorHandler handler = containerDescriptorHandlers.get(hint);
if (handler == null) {
throw new InvalidAssemblerConfigurationException("Cannot find ContainerDescriptorHandler with hint: " + hint);
}
getLogger().debug("Found container descriptor handler with hint: " + hint + " (component: " + handler + ")");
if (config.getConfiguration() != null) {
getLogger().debug("Configuring handler with:\n\n" + config.getConfiguration() + "\n\n");
configureContainerDescriptorHandler(handler, (Xpp3Dom) config.getConfiguration(), configSource);
}
handlers.add(handler);
hints.add(hint);
}
}
if (!hints.contains("plexus")) {
handlers.add(new ComponentsXmlArchiverFileFilter());
}
return handlers;
}
use of org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method configureContainerDescriptorHandler.
private void configureContainerDescriptorHandler(final ContainerDescriptorHandler handler, final Xpp3Dom config, final AssemblerConfigurationSource configSource) throws InvalidAssemblerConfigurationException {
getLogger().debug("Configuring handler: '" + handler.getClass().getName() + "' -->");
try {
configureComponent(handler, config, configSource);
} catch (final ComponentConfigurationException e) {
throw new InvalidAssemblerConfigurationException("Failed to configure handler: " + handler.getClass().getName(), e);
} catch (final ComponentLookupException e) {
throw new InvalidAssemblerConfigurationException("Failed to lookup configurator for setup of handler: " + handler.getClass().getName(), e);
}
getLogger().debug("-- end configuration --");
}
use of org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException in project docker-maven-plugin by fabric8io.
the class ArchiveService method getAssemblyFiles.
/**
* Get a mapping of original to destination files which a covered by an assembly. This can be used
* to watch the source files for changes in order to update the target (either by recreating a docker image
* or by copying it into a running container)
*
* @param imageConfig image config for which to get files. The build- and assembly configuration in this image
* config must not be null.
* @param mojoParameters needed for tracking the assembly
* @return mapping of assembly files
* @throws MojoExecutionException
*/
public AssemblyFiles getAssemblyFiles(ImageConfiguration imageConfig, String assemblyName, MojoParameters mojoParameters) throws MojoExecutionException {
String name = imageConfig.getName();
try {
List<AssemblyConfiguration> assemblyConfigurations = imageConfig.getBuildConfiguration().getAssemblyConfigurations();
AssemblyConfiguration assemblyConfig = assemblyConfigurations.stream().filter(a -> a.getName().equals(assemblyName)).findFirst().orElse(null);
if (assemblyConfig == null) {
throw new IllegalArgumentException(String.format("Provided assembly name \"%s\" does not match any configured assemblies.", assemblyName));
}
return dockerAssemblyManager.getAssemblyFiles(name, assemblyConfig, mojoParameters, log);
} catch (InvalidAssemblerConfigurationException | ArchiveCreationException | AssemblyFormattingException e) {
throw new MojoExecutionException("Cannot extract assembly files for image " + name + ": " + e, e);
}
}
Aggregations