Search in sources :

Example 66 with ArchiverException

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();
}
Also used : ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 67 with ArchiverException

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();
}
Also used : ArchiverException(org.codehaus.plexus.archiver.ArchiverException) File(java.io.File)

Example 68 with ArchiverException

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();
}
Also used : ArchiverException(org.codehaus.plexus.archiver.ArchiverException) File(java.io.File)

Example 69 with ArchiverException

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();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ArchiverManager(org.codehaus.plexus.archiver.manager.ArchiverManager) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) File(java.io.File) UnArchiver(org.codehaus.plexus.archiver.UnArchiver) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException)

Example 70 with ArchiverException

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;
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) IOException(java.io.IOException) File(java.io.File)

Aggregations

ArchiverException (org.codehaus.plexus.archiver.ArchiverException)99 File (java.io.File)69 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)54 IOException (java.io.IOException)48 NoSuchArchiverException (org.codehaus.plexus.archiver.manager.NoSuchArchiverException)28 UnArchiver (org.codehaus.plexus.archiver.UnArchiver)18 ManifestException (org.codehaus.plexus.archiver.jar.ManifestException)15 MavenArchiver (org.apache.maven.archiver.MavenArchiver)14 Artifact (org.apache.maven.artifact.Artifact)14 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)14 Archiver (org.codehaus.plexus.archiver.Archiver)8 Resource (org.apache.maven.model.Resource)7 IncludeExcludeFileSelector (org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector)7 MojoFailureException (org.apache.maven.plugin.MojoFailureException)6 DefaultFileSet (org.codehaus.plexus.archiver.util.DefaultFileSet)6 ArrayList (java.util.ArrayList)5 ArchiveCreationException (org.apache.maven.plugins.assembly.archive.ArchiveCreationException)5 MavenProject (org.apache.maven.project.MavenProject)5 FileInputStream (java.io.FileInputStream)4 FileWriter (java.io.FileWriter)4