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);
}
}
Aggregations