Search in sources :

Example 1 with TarUnArchiver

use of org.codehaus.plexus.archiver.tar.TarUnArchiver in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManager method extractDockerTarArchive.

/**
 * Extract a docker tar archive into the given directory.
 *
 * @param archiveFile a tar archive to extract
 * @param destinationDirectory directory where to place extracted content
 * @throws MojoExecutionException if an error occurs during extracting.
 */
public void extractDockerTarArchive(File archiveFile, File destinationDirectory) throws MojoExecutionException {
    try {
        TarUnArchiver unArchiver = (TarUnArchiver) archiverManager.getUnArchiver(TAR_ARCHIVER_TYPE);
        unArchiver.setCompression(UntarCompressionMethod.NONE);
        unArchiver.setSourceFile(archiveFile);
        unArchiver.setDestDirectory(destinationDirectory);
        unArchiver.extract();
    } catch (NoSuchArchiverException e) {
        throw new MojoExecutionException("No archiver found for file " + archiveFile, e);
    } catch (ArchiverException e) {
        throw new MojoExecutionException("Cannot extract archive " + archiveFile, e);
    }
}
Also used : TarUnArchiver(org.codehaus.plexus.archiver.tar.TarUnArchiver) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException)

Aggregations

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)1 NoSuchArchiverException (org.codehaus.plexus.archiver.manager.NoSuchArchiverException)1 TarUnArchiver (org.codehaus.plexus.archiver.tar.TarUnArchiver)1