Search in sources :

Example 11 with UnArchiver

use of org.codehaus.plexus.archiver.UnArchiver in project sling by apache.

the class PreparePackageMojo method unpack.

/**
     * Unpack a file
     */
private void unpack(final File source, final File destination) throws MojoExecutionException {
    getLog().debug("Unpacking " + source.getPath() + " to\n  " + destination.getPath());
    try {
        destination.mkdirs();
        final UnArchiver unArchiver = archiverManager.getUnArchiver(source);
        unArchiver.setSourceFile(source);
        unArchiver.setDestDirectory(destination);
        unArchiver.extract();
    } catch (final NoSuchArchiverException e) {
        throw new MojoExecutionException("Unable to find archiver for " + source.getPath(), e);
    } catch (final ArchiverException e) {
        throw new MojoExecutionException("Unable to unpack " + source.getPath(), e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) UnArchiver(org.codehaus.plexus.archiver.UnArchiver) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException)

Aggregations

UnArchiver (org.codehaus.plexus.archiver.UnArchiver)11 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)9 NoSuchArchiverException (org.codehaus.plexus.archiver.manager.NoSuchArchiverException)9 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 File (java.io.File)4 Artifact (org.apache.maven.artifact.Artifact)3 IncludeExcludeFileSelector (org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector)3 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)2 ArchiverManager (org.codehaus.plexus.archiver.manager.ArchiverManager)2 ZipUnArchiver (org.codehaus.plexus.archiver.zip.ZipUnArchiver)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 JarFile (java.util.jar.JarFile)1 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)1 ArtifactHandlerManager (org.apache.maven.artifact.handler.manager.ArtifactHandlerManager)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)1