Package org.codehaus.plexus.archiver.tar

Examples of org.codehaus.plexus.archiver.tar.TarArchiver$TarOptions


    }

    protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode )
        throws NoSuchArchiverException, ArchiverException
    {
        final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" );
        final int index = format.indexOf( '.' );
        if ( index >= 0 )
        {
            TarArchiver.TarCompressionMethod tarCompressionMethod;
            // TODO: this should accept gz and bz2 as well so we can skip
            // over the switch
            final String compression = format.substring( index + 1 );
            if ( "gz".equals( compression ) )
            {
                tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip;
            }
            else if ( "bz2".equals( compression ) )
            {
                tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2;
            }
            else
            {
                // TODO: better handling
                throw new IllegalArgumentException( "Unknown compression format: " + compression );
            }
            tarArchiver.setCompression( tarCompressionMethod );
        }
        else if ( "tgz".equals( format ) )
        {
            tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip );
        }
        else if ( "tbz2".equals( format ) )
        {
            tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 );
        }

        tarArchiver.setLongfile( tarLongFileMode );

        return tarArchiver;
    }
View Full Code Here


            return answer;
        }
    }

    protected void createDockerArchive(File archive, File dockerDir) throws IOException {
        TarArchiver archiver = new TarArchiver();
        archiver.addDirectory(dockerDir);
        archiver.setDestFile(archive);
        archiver.createArchive();
    }
View Full Code Here

            final GZipArchiver gzip = new GZipArchiver();
            gzip.setDestFile(metadataGz);
            gzip.addFile(metadata, "metadata.gz");
            gzip.createArchive();

            final TarArchiver tar = new TarArchiver();
            // turn off logging
            tar.enableLogging(new AbstractLogger(0, "nologging") {

                public void warn(final String message, final Throwable throwable) {
                }

                public void info(final String message, final Throwable throwable) {
                }

                public Logger getChildLogger(final String name) {
                    return null;
                }

                public void fatalError(final String message,
                        final Throwable throwable) {
                }

                public void error(final String message,
                        final Throwable throwable) {
                }

                public void debug(final String message,
                        final Throwable throwable) {
                }
            });
            final TarCompressionMethod compression = new TarCompressionMethod();
            File dataTarGz = null;
            if (!gem.getGemFiles().isEmpty()) {
                // tar.gz the content into data.tar.gz
                dataTarGz = new File(gemWorkdir, "data.tar.gz");
                compression.setValue("gzip");
                tar.setCompression(compression);
                tar.setDestFile(dataTarGz);
                for (final GemFileEntry entry : gem.getGemFiles()) {
                    if (entry.getSource().isFile()) {
                        tar.addFile(entry.getSource(), entry.getPathInGem());
                    }
                    else if (entry.getSource().isDirectory()) {
                        tar.addDirectory(entry.getSource(),
                                         entry.getPathInGem());
                    }
                }
                tar.createArchive();
            }

            // and finally create gem by tar.gz-ing data.tar.gz and metadata.gz
            final File gemFile = new File(target, gem.getGemFilename());
            tar.setDestFile(gemFile);
            compression.setValue("none");
            tar.setCompression(compression);
            if (dataTarGz != null) {
                tar.addFile(dataTarGz, dataTarGz.getName());
            }
            tar.addFile(metadataGz, metadataGz.getName());
            tar.createArchive();

            return gemFile;
        }
        catch (final ArchiverException e) {
            final IOException ioe = new IOException(e.getMessage());
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.tar.TarArchiver$TarOptions

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.