use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithUnpack.
public void testShouldAddArchiveFileWithUnpack() throws ArchiveCreationException, AssemblyFormattingException, IOException {
mac.expectModeChange(-1, -1, -1, -1, 1);
mac.expectInterpolators();
ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
artifactMock.setNewFile();
mac.expectGetDestFile(new File("junk"));
try {
// mac.archiver.addArchivedFileSet( artifactFile, outputLocation, AddArtifactTask.DEFAULT_INCLUDES_ARRAY,
// null );
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.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AddDirectoryTaskTest method testAddDirectory_ShouldAddDirectoryWithIncludesAndExcludes.
public void testAddDirectory_ShouldAddDirectoryWithIncludesAndExcludes() throws ArchiveCreationException {
File dir = fileManager.createTempDir();
try {
archiver.addFileSet((FileSet) anyObject());
} catch (ArchiverException e) {
fail("Should never happen.");
}
configureModeExpectations(-1, -1, -1, -1, false);
mockManager.replayAll();
AddDirectoryTask task = new AddDirectoryTask(dir);
task.setIncludes(Collections.singletonList("**/*.txt"));
task.setExcludes(Collections.singletonList("**/README.txt"));
task.setOutputDirectory("dir");
task.execute(archiver);
mockManager.verifyAll();
}
use of org.codehaus.plexus.archiver.ArchiverException in project maven-plugins by apache.
the class AddDirectoryTaskTest method testAddDirectory_ShouldAddDirectoryWithDirMode.
public void testAddDirectory_ShouldAddDirectoryWithDirMode() throws ArchiveCreationException {
File dir = fileManager.createTempDir();
try {
archiver.addFileSet((FileSet) anyObject());
} catch (ArchiverException e) {
fail("Should never happen.");
}
int dirMode = Integer.parseInt("777", 8);
int fileMode = Integer.parseInt("777", 8);
configureModeExpectations(-1, -1, dirMode, fileMode, true);
mockManager.replayAll();
AddDirectoryTask task = new AddDirectoryTask(dir);
task.setDirectoryMode(dirMode);
task.setFileMode(fileMode);
task.setOutputDirectory("dir");
task.execute(archiver);
mockManager.verifyAll();
}
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 JLinkMojo method createZipArchiveFromImage.
private File createZipArchiveFromImage(File outputDirectory, File outputDirectoryImage) throws MojoExecutionException {
zipArchiver.addDirectory(outputDirectoryImage);
File resultArchive = getArchiveFile(outputDirectory, finalName, null, "zip");
zipArchiver.setDestFile(resultArchive);
try {
zipArchiver.createArchive();
} catch (ArchiverException e) {
getLog().error(e.getMessage(), e);
throw new MojoExecutionException(e.getMessage(), e);
} catch (IOException e) {
getLog().error(e.getMessage(), e);
throw new MojoExecutionException(e.getMessage(), e);
}
return resultArchive;
}
Aggregations