Package org.codehaus.plexus.archiver

Examples of org.codehaus.plexus.archiver.UnArchiver


  private void unpack(final File file, final File location)
      throws MojoExecutionException, NoSuchArchiverException {
    final String archiveExt = FileUtils.getExtension(file.getAbsolutePath()).toLowerCase(Locale.ENGLISH);
    try {
      final UnArchiver unArchiver = archiverManager.getUnArchiver(archiveExt);
      unArchiver.setSourceFile(file);
      unArchiver.setDestDirectory(location);
      unArchiver.extract();
    } catch (final ArchiverException e) {
      throw new MojoExecutionException("Error unpacking file: " + file + "to: " + location, e);
    }
  }
View Full Code Here


     * @param destDir Location where to put the unpacked files.
     */
    public void unpack( File source, File destDir )
        throws NoSuchArchiverException, IOException
    {
        UnArchiver unArchiver = archiverManager.getUnArchiver( "zip" );
        unArchiver.setSourceFile( source );
        unArchiver.setDestDirectory( destDir );

        // Extract the module
        unArchiver.extract();
    }
View Full Code Here

        new Gav("org.apache.maven", "apache-maven", "3.0.3", "bin", "tar.gz", null, null, null, false, null,
            false, null);
    File bundle =
        downloadArtifact(getNexusTestRepoUrl(), gav, "target/downloads/nexus4218/" + gav.getArtifactId() + "-" + gav.getVersion());

    UnArchiver unArchive = TestContainer.getInstance().getPlexusContainer().lookup(ArchiverManager.class).getUnArchiver(bundle);
    unArchive.setSourceFile(bundle);
    unArchive.setDestDirectory(bundle.getParentFile());
    unArchive.extract();

    final StringBuilder sb = new StringBuilder();
    StreamConsumer out = new StreamConsumer()
    {
      public void consumeLine(String line) {
View Full Code Here

        new Gav("org.apache.maven", "apache-maven", "2.0.6", "bin", "tar.gz", null, null, null, false, null,
            false, null);
    File bundle =
        downloadArtifact(getNexusTestRepoUrl(), gav, "target/downloads/nexus4218/" + gav.getArtifactId() + "-" + gav.getVersion());

    UnArchiver unArchive = TestContainer.getInstance().getPlexusContainer().lookup(ArchiverManager.class).getUnArchiver(bundle);
    unArchive.setSourceFile(bundle);
    unArchive.setDestDirectory(bundle.getParentFile());
    unArchive.extract();

    final StringBuilder sb = new StringBuilder();
    StreamConsumer out = new StreamConsumer()
    {
      public void consumeLine(String line) {
View Full Code Here

        new Gav("org.apache.ivy", "apache-ivy", "2.2.0", "bin", "tar.gz", null, null, null, false, null, false,
            null);
    File bundle =
        downloadArtifact(getNexusTestRepoUrl(), gav, "target/downloads/nexus4218/" + gav.getArtifactId() + "-" + gav.getVersion());

    UnArchiver unArchive = TestContainer.getInstance().getPlexusContainer().lookup(ArchiverManager.class).getUnArchiver(bundle);
    unArchive.setSourceFile(bundle);
    unArchive.setDestDirectory(bundle.getParentFile());
    unArchive.extract();

    final StringBuilder sb = new StringBuilder();
    StreamConsumer out = new StreamConsumer()
    {
      public void consumeLine(String line) {
View Full Code Here

                // usual case is a future jar packaging, but there are special cases: classifier and other packaging
                throw new MojoExecutionException( "Artifact has not been packaged yet. When used on reactor artifact, "
                    + "unpack should be executed after packaging: see MDEP-98." );
            }

            UnArchiver unArchiver;

            try
            {
                unArchiver = archiverManager.getUnArchiver( artifact.getType() );
                getLog().debug( "Found unArchiver by type: " + unArchiver );
            }
            catch ( NoSuchArchiverException e )
            {
                unArchiver = archiverManager.getUnArchiver( file );
                getLog().debug( "Found unArchiver by extension: " + unArchiver );
            }

            unArchiver.setUseJvmChmod( useJvmChmod );

            unArchiver.setIgnorePermissions( ignorePermissions );

            unArchiver.setSourceFile( file );

            unArchiver.setDestDirectory( location );

            if ( StringUtils.isNotEmpty( excludes ) || StringUtils.isNotEmpty( includes ) )
            {
                // Create the selectors that will filter
                // based on include/exclude parameters
                // MDEP-47
                IncludeExcludeFileSelector[] selectors =
                    new IncludeExcludeFileSelector[]{ new IncludeExcludeFileSelector() };

                if ( StringUtils.isNotEmpty( excludes ) )
                {
                    selectors[0].setExcludes( excludes.split( "," ) );
                }

                if ( StringUtils.isNotEmpty( includes ) )
                {
                    selectors[0].setIncludes( includes.split( "," ) );
                }

                unArchiver.setFileSelectors( selectors );
            }
            if ( this.silent )
            {
                silenceUnarchiver( unArchiver );
            }

            unArchiver.extract();
        }
        catch ( NoSuchArchiverException e )
        {
            throw new MojoExecutionException( "Unknown archiver type", e );
        }
View Full Code Here

        File file = artifact.getFile();

        String archiveExt = FileUtils.getExtension(file.getAbsolutePath()).toLowerCase();

        try {
            UnArchiver unArchiver = archiverManager.getUnArchiver(archiveExt);
            unArchiver.setSourceFile(file);
            unArchiver.setDestDirectory(location);
            unArchiver.extract();
        }
        catch (NoSuchArchiverException e) {
            throw new MojoExecutionException("Unknown archiver type", e);
        }
        catch (IOException e) {
View Full Code Here

        File outputDirectory = new File( mavenProject.getBuild().getDirectory() );

        try
        {
            UnArchiver ua = new ZipUnArchiver( pluginJar );

            ua.extract( resourcesPath, outputDirectory );
        }
        catch ( ArchiverException e )
        {
            throw new MojoExecutionException( "Error extracting resources from your Ant-based plugin.", e );
        }
View Full Code Here

     * @param destDir Location where to put the unpacked files.
     */
    public void unpack( File source, File destDir )
        throws NoSuchArchiverException, IOException, ArchiverException
    {
        UnArchiver unArchiver = archiverManager.getUnArchiver( "zip" );
        unArchiver.setSourceFile( source );
        unArchiver.setDestDirectory( destDir );

        // Extract the module
        unArchiver.extract();
    }
View Full Code Here

        if ( isEmpty( resourcesArtifacts ) )
        {
            return;
        }

        UnArchiver unArchiver;
        try
        {
            unArchiver = archiverManager.getUnArchiver( "jar" );
        }
        catch ( NoSuchArchiverException e )
        {
            throw new MavenReportException(
                "Unable to extract resources artifact. " + "No archiver for 'jar' available.", e );
        }

        for ( ResourcesArtifact item : resourcesArtifacts )
        {
            Artifact artifact;
            try
            {
                artifact = createAndResolveArtifact( item );
            }
            catch ( ArtifactResolutionException e )
            {
                throw new MavenReportException( "Unable to resolve artifact:" + item, e );
            }
            catch ( ArtifactNotFoundException e )
            {
                throw new MavenReportException( "Unable to find artifact:" + item, e );
            }
            catch ( ProjectBuildingException e )
            {
                throw new MavenReportException( "Unable to build the Maven project for the artifact:" + item, e );
            }

            unArchiver.setSourceFile( artifact.getFile() );
            unArchiver.setDestDirectory( anOutputDirectory );
            // remove the META-INF directory from resource artifact
            IncludeExcludeFileSelector[] selectors =
                new IncludeExcludeFileSelector[]{ new IncludeExcludeFileSelector() };
            selectors[0].setExcludes( new String[]{ "META-INF/**" } );
            unArchiver.setFileSelectors( selectors );

            getLog().info( "Extracting contents of resources artifact: " + artifact.getArtifactId() );
            try
            {
                unArchiver.extract();
            }
            catch ( ArchiverException e )
            {
                throw new MavenReportException(
                    "Extraction of resources failed. Artifact that failed was: " + artifact.getArtifactId(), e );
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.UnArchiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.