use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class ManifestCreationFinalizer method finalizeArchiveCreation.
@Override
public void finalizeArchiveCreation(final Archiver archiver) {
if (archiveConfiguration != null) {
try {
Manifest manifest;
final File manifestFile = archiveConfiguration.getManifestFile();
if (manifestFile != null) {
Reader manifestFileReader = null;
try {
manifestFileReader = new InputStreamReader(new FileInputStream(manifestFile), "UTF-8");
manifest = new Manifest(manifestFileReader);
manifestFileReader.close();
manifestFileReader = null;
} catch (final FileNotFoundException e) {
throw new ArchiverException("Manifest not found: " + e.getMessage(), e);
} catch (final IOException e) {
throw new ArchiverException("Error processing manifest: " + e.getMessage(), e);
} finally {
IOUtil.close(manifestFileReader);
}
} else {
manifest = mavenArchiver.getManifest(session, project, archiveConfiguration);
}
if ((manifest != null) && (archiver instanceof JarArchiver)) {
final JarArchiver jarArchiver = (JarArchiver) archiver;
jarArchiver.addConfiguredManifest(manifest);
}
} catch (final ManifestException e) {
throw new ArchiverException("Error creating manifest: " + e.getMessage(), e);
} catch (final DependencyResolutionRequiredException e) {
throw new ArchiverException("Dependencies were not resolved: " + e.getMessage(), e);
}
}
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method configureArchiver.
private void configureArchiver(final Archiver archiver, final AssemblerConfigurationSource configSource) {
Xpp3Dom config;
try {
config = Xpp3DomBuilder.build(new StringReader(configSource.getArchiverConfig()));
} catch (final XmlPullParserException e) {
throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
} catch (final IOException e) {
throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
}
getLogger().debug("Configuring archiver: '" + archiver.getClass().getName() + "' -->");
try {
configureComponent(archiver, config, configSource);
} catch (final ComponentConfigurationException e) {
throw new ArchiverException("Failed to configure archiver: " + archiver.getClass().getName(), e);
} catch (final ComponentLookupException e) {
throw new ArchiverException("Failed to lookup configurator for setup of archiver: " + archiver.getClass().getName(), e);
}
getLogger().debug("-- end configuration --");
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AbstractWarMojoTest method createArchive.
protected void createArchive(final File directory, final File destinationFile) {
try {
// WarArchiver archiver = new WarArchiver();
Archiver archiver = new JarArchiver();
archiver.setUseJvmChmod(true);
archiver.setDestFile(destinationFile);
archiver.addDirectory(directory);
// archiver.setWebxml( new File(directory, "WEB-INF/web.xml"));
// create archive
archiver.createArchive();
} catch (ArchiverException e) {
e.printStackTrace();
fail("Failed to create overlay archive " + e.getMessage());
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected exception " + e.getMessage());
}
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AssemblyFileUtilsTest method testUnpack_ShouldSetSourceAndDestinationAndCallExtract.
public void testUnpack_ShouldSetSourceAndDestinationAndCallExtract() throws IOException, ArchiveExpansionException, NoSuchArchiverException {
EasyMockSupport mockManager = new EasyMockSupport();
File source = fileManager.createTempFile();
File destDir = fileManager.createTempDir();
UnArchiver unarchiver = mockManager.createMock(UnArchiver.class);
ArchiverManager archiverManager = mockManager.createMock(ArchiverManager.class);
try {
expect(archiverManager.getUnArchiver(source)).andReturn(unarchiver);
} catch (NoSuchArchiverException e) {
fail("Should never happen.");
}
unarchiver.setSourceFile(source);
unarchiver.setDestDirectory(destDir);
try {
unarchiver.extract();
} catch (ArchiverException e) {
fail("Should never happen.");
}
mockManager.replayAll();
AssemblyFileUtils.unpack(source, destDir, archiverManager);
mockManager.verifyAll();
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class EjbMojo method generateEjb.
private File generateEjb() throws MojoExecutionException {
File jarFile = EjbHelper.getJarFile(outputDirectory, jarName, getClassifier());
getLog().info("Building EJB " + jarName + " with EJB version " + ejbVersion);
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
archiver.setOutputFile(jarFile);
File deploymentDescriptor = new File(sourceDirectory, ejbJar);
checkEJBVersionCompliance(deploymentDescriptor);
try {
List<String> defaultExcludes = Lists.newArrayList(ejbJar, "**/package.html");
List<String> defaultIncludes = DEFAULT_INCLUDES_LIST;
IncludesExcludes ie = new IncludesExcludes(Collections.<String>emptyList(), excludes, defaultIncludes, defaultExcludes);
archiver.getArchiver().addDirectory(sourceDirectory, ie.resultingIncludes(), ie.resultingExcludes());
// FIXME: We should be able to filter more than just the deployment descriptor?
if (deploymentDescriptor.exists()) {
// EJB-34 Filter ejb-jar.xml
if (filterDeploymentDescriptor) {
filterDeploymentDescriptor(deploymentDescriptor);
}
archiver.getArchiver().addFile(deploymentDescriptor, ejbJar);
}
// create archive
archiver.createArchive(session, project, archive);
} catch (ArchiverException e) {
throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
} catch (IOException e) {
throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
} catch (MavenFilteringException e) {
throw new MojoExecutionException("There was a problem filtering the deployment descriptor: " + e.getMessage(), e);
}
return jarFile;
}
Aggregations