use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class SimpleAggregatingDescriptorHandler method finalizeArchiveCreation.
@Override
public void finalizeArchiveCreation(final Archiver archiver) {
checkConfig();
if (outputPath.endsWith("/")) {
throw new ArchiverException("Cannot write aggregated properties to a directory. " + "You must specify a file name in the outputPath configuration for this" + " handler. (handler: " + getClass().getName());
}
if (outputPath.startsWith("/")) {
outputPath = outputPath.substring(1);
}
final File temp = writePropertiesFile();
overrideFilterAction = true;
archiver.addFile(temp, outputPath);
overrideFilterAction = false;
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchive.
@Test
public void testCreateArchive() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException, IOException, DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver(mm);
macMgr.expectGetArchiver("zip", Archiver.class);
macMgr.expectGetDestFile(new File("test"));
final AssemblyArchiverPhase phase = mm.createControl().createMock(AssemblyArchiverPhase.class);
phase.execute((Assembly) anyObject(), (Archiver) anyObject(), (AssemblerConfigurationSource) anyObject());
final AssemblerConfigurationSource configSource = mm.createControl().createMock(AssemblerConfigurationSource.class);
final File tempDir = fileManager.createTempDir();
FileUtils.deleteDirectory(tempDir);
expect(configSource.getTemporaryRootDirectory()).andReturn(tempDir).anyTimes();
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.isIgnoreDirFormatExtensions()).andReturn(false).anyTimes();
final File outDir = fileManager.createTempDir();
macMgr.archiver.setDestFile(new File(outDir, "full-name.zip"));
try {
macMgr.archiver.createArchive();
} catch (final ArchiverException e) {
fail("Should never happen");
} catch (final IOException e) {
fail("Should never happen");
}
expect(configSource.getOutputDirectory()).andReturn(outDir);
expect(configSource.getFinalName()).andReturn("finalName");
expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
expect(configSource.getWorkingDirectory()).andReturn(new File(".")).anyTimes();
expect(configSource.isUpdateOnly()).andReturn(false).anyTimes();
expect(configSource.isIgnorePermissions()).andReturn(false).anyTimes();
final Assembly assembly = new Assembly();
assembly.setId("id");
// try
// {
// expect( macMgr.dependencyResolver.resolve( (Assembly) anyObject(), (AssemblerConfigurationSource)
// anyObject() )).andReturn( new HashSet<Artifact>( ) );
// macMgr.dependencyResolverControl.setMatcher( MockControl.ALWAYS_MATCHER );
// }
// catch ( final DependencyResolutionException e )
// {
// fail( "Should never happen" );
// }
mm.replayAll();
final DefaultAssemblyArchiver subject = createSubject(macMgr, Collections.singletonList(phase), null);
subject.createArchive(assembly, "full-name", "zip", configSource, false, null);
mm.verifyAll();
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AssemblyFileUtils method unpack.
/**
* Unpacks the archive file.
*
* @param source File to be unpacked.
* @param destDir Location where to put the unpacked files.
*/
public static void unpack(File source, File destDir, ArchiverManager archiverManager) throws ArchiveExpansionException, NoSuchArchiverException {
try {
UnArchiver unArchiver = archiverManager.getUnArchiver(source);
unArchiver.setSourceFile(source);
unArchiver.setDestDirectory(destDir);
unArchiver.extract();
} catch (ArchiverException e) {
throw new ArchiveExpansionException("Error unpacking file: " + source + "to: " + destDir, e);
}
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithUnpackAndModes.
public void testShouldAddArchiveFileWithUnpackAndModes() throws ArchiveCreationException, AssemblyFormattingException, IOException {
int directoryMode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
int fileMode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
mac.expectModeChange(-1, -1, directoryMode, fileMode, 2);
mac.expectInterpolators();
ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
artifactMock.setNewFile();
mac.expectGetDestFile(new File("junk"));
try {
mac.archiver.addArchivedFileSet((ArchivedFileSet) anyObject(), (Charset) anyObject());
} catch (ArchiverException e) {
fail("Should never happen.");
}
mockManager.replayAll();
AddArtifactTask task = createTask(artifactMock.getArtifact());
task.setUnpack(true);
task.setDirectoryMode(directoryMode);
task.setFileMode(fileMode);
task.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class EjbMojo method generateEjbClient.
private File generateEjbClient() throws MojoExecutionException {
File clientJarFile = EjbHelper.getJarFile(outputDirectory, jarName, getClientClassifier());
getLog().info("Building EJB client " + clientJarFile.getPath());
MavenArchiver clientArchiver = new MavenArchiver();
clientArchiver.setArchiver(clientJarArchiver);
clientArchiver.setOutputFile(clientJarFile);
try {
List<String> defaultExcludes = DEFAULT_CLIENT_EXCLUDES_LIST;
List<String> defaultIncludes = DEFAULT_INCLUDES_LIST;
IncludesExcludes ie = new IncludesExcludes(clientIncludes, clientExcludes, defaultIncludes, defaultExcludes);
clientArchiver.getArchiver().addDirectory(sourceDirectory, ie.resultingIncludes(), ie.resultingExcludes());
clientArchiver.createArchive(session, project, archive);
} catch (ArchiverException e) {
throw new MojoExecutionException("There was a problem creating the EJB client archive: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("There was a problem creating the EJB client archive: " + e.getMessage(), e);
} catch (IOException e) {
throw new MojoExecutionException("There was a problem creating the EJB client archive: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("There was a problem creating the EJB client archive: " + e.getMessage(), e);
}
return clientJarFile;
}
Aggregations