Examples of Archiver


Examples of hudson.util.io.Archiver

     */
    public int archive(final ArchiverFactory factory, OutputStream os, final DirScanner scanner) throws IOException, InterruptedException {
        final OutputStream out = (channel!=null)?new RemoteOutputStream(os):os;
        return act(new FileCallable<Integer>() {
            public Integer invoke(File f, VirtualChannel channel) throws IOException {
                Archiver a = factory.create(out);
                try {
                    scanner.scan(f,a);
                } finally {
                    a.close();
                }
                return a.countEntries();
            }

            private static final long serialVersionUID = 1L;
        });
    }
View Full Code Here

Examples of hudson.util.io.Archiver

     *
     * @return
     *      number of files/directories that are written.
     */
    private static Integer writeToTar(File baseDir, String fileMask, String excludes, OutputStream out) throws IOException {
        Archiver tw = ArchiverFactory.TAR.create(out);
        try {
            new DirScanner.Glob(fileMask,excludes).scan(baseDir,tw);
        } finally {
            tw.close();
        }
        return tw.countEntries();
    }
View Full Code Here

Examples of hudson.util.io.Archiver

     */
    public int archive(final ArchiverFactory factory, OutputStream os, final DirScanner scanner) throws IOException, InterruptedException {
        final OutputStream out = (channel!=null)?new RemoteOutputStream(os):os;
        return act(new FileCallable<Integer>() {
            public Integer invoke(File f, VirtualChannel channel) throws IOException {
                Archiver a = factory.create(out);
                try {
                    scanner.scan(f,a);
                } finally {
                    a.close();
                }
                return a.countEntries();
            }

            private static final long serialVersionUID = 1L;
        });
    }
View Full Code Here

Examples of hudson.util.io.Archiver

     *
     * @return
     *      number of files/directories that are written.
     */
    private static Integer writeToTar(File baseDir, String fileMask, String excludes, OutputStream out) throws IOException {
        Archiver tw = ArchiverFactory.TAR.create(out);
        try {
            new DirScanner.Glob(fileMask,excludes).scan(baseDir,tw);
        } finally {
            tw.close();
        }
        return tw.countEntries();
    }
View Full Code Here

Examples of org.codehaus.plexus.archiver.Archiver

        final File file) throws MojoExecutionException
    {
        final String archiveExt = FileUtils.getExtension(file.getAbsolutePath()).toLowerCase();
        try
        {
            final Archiver archiver;
            archiver = this.archiverManager.getArchiver(archiveExt);
            archiver.setDestFile(file);
            archiver.addDirectory(location);
            archiver.createArchive();
        }
        catch (Throwable throwable)
        {
            if (throwable instanceof IOException || throwable instanceof ArchiverException)
            {
View Full Code Here

Examples of org.codehaus.plexus.archiver.Archiver

     * @required
     */
    private File xarDirectory;
   
    public void execute() throws MojoExecutionException {
        Archiver archiver = new DirectoryArchiver();
        archiver.setDestFile(xarDirectory);
        try {
            buildArchive(archiver);
            archiver.createArchive();
        } catch (ArchiverException e) {
            throw new MojoExecutionException("Unable to build archive", e);
        } catch (IOException e) {
            throw new MojoExecutionException("Unable to build archive", e);
        }
View Full Code Here

Examples of org.codehaus.plexus.archiver.Archiver

    public File archive(String sourcePath, String destPath, Artifact artifact) throws ArchiverException, IOException {
        File source = serverInfo.resolve(sourcePath);
        File dest = serverInfo.resolve(destPath);
        String serverName = artifact.getArtifactId() + "-" + artifact.getVersion();
        dest = new File(dest, serverName + "-bin." + artifact.getType());
        Archiver archiver;
        if ("tar.gz".equals(artifact.getType())) {
            archiver = new TarArchiver();
            TarArchiver.TarCompressionMethod tarCompressionMethod = new TarArchiver.TarCompressionMethod();
            tarCompressionMethod.setValue("gzip");
            ((TarArchiver) archiver).setCompression(tarCompressionMethod);
            TarLongFileMode fileMode = new TarLongFileMode();
            fileMode.setValue(TarLongFileMode.GNU);
            ((TarArchiver) archiver).setLongfile(fileMode);
        } else if ("zip".equals(artifact.getType())) {
            archiver = new ZipArchiver();
        } else {
            throw new IllegalArgumentException("Unknown target type: " + artifact.getType());
        }
        archiver.setIncludeEmptyDirs(true);
        archiver.setDestFile(dest);
/* see if using plexus-archiver 1.0-alpha-7 same as maven lets us share code.  Following is for 1.0-alpha-9
        DefaultFileSet all = new DefaultFileSet();
        all.setDirectory(source);
        archiver.addFileSet(all);
*/
       
        // add in all files and mark them with default file permissions
        Map<String, File> all = IOUtil.listAllFileNames(source);
        for (Map.Entry<String, File> entry : all.entrySet()) {
            String destFileName = serverName + "/" + entry.getKey();
            File sourceFile = entry.getValue();
            if (sourceFile.isFile()) {
                archiver.addFile(sourceFile, destFileName, UnixStat.DEFAULT_FILE_PERM);
            }
        }

        // add execute permissions to all non-batch files in the bin/ directory
        File bin = new File(source, "bin");
        if (bin.exists()) {
            Map<String, File> includes = IOUtil.listAllFileNames(bin);
            for (Map.Entry<String, File> entry : includes.entrySet()) {
                String destFileName = serverName + "/bin/" + entry.getKey();
                File sourceFile = entry.getValue();
                if (!destFileName.endsWith(".bat") && sourceFile.isFile()) {
                    archiver.addFile(sourceFile, destFileName, UnixStat.DEFAULT_DIR_PERM);
                }
            }
        }
       
        archiver.createArchive();
        return dest;
    }
View Full Code Here

Examples of org.codehaus.plexus.archiver.Archiver

            // BUILD UBER-ZIP OF ARTIFACT + DEPENDENCIES

            getLog().info( "Processing: " + inputFile );

            final File uberZip = new File( workingDirectory, "uber-" + inputFile.getName() );
            final Archiver archiver = archiverManager.getArchiver( "zip" );

            archiver.setDestFile( uberZip );

            if ( inputFile.isDirectory() )
            {
                archiver.addDirectory( inputFile );
            }
            else
            {
                archiver.addArchivedFileSet( inputFile );
            }

            for ( final Artifact a : (Set<Artifact>) project.getArtifacts() )
            {
                if ( filter.include( a ) )
                {
                    try
                    {
                        archiver.addArchivedFileSet( a.getFile(), null, META_INF_EXCLUDES );
                    }
                    catch ( final Throwable e )
                    {
                        getLog().info( "Ignoring: " + a );
                        getLog().debug( e );
                    }
                }
            }

            if ( !archiver.getResources().hasNext() )
            {
                getLog().info( "Nothing to JarJar" );
                return;
            }

            archiver.createArchive();

            // JARJAR UBER-ZIP

            getLog().info( "JarJar'ing to: " + outputFile );
View Full Code Here

Examples of org.codehaus.plexus.archiver.Archiver

    @Test
    public void addFile_NoPerms_CallAcceptFilesOnlyOnce()
        throws IOException, ArchiverException
    {
        final MockControl delegateControl = MockControl.createControl( Archiver.class );
        final Archiver delegate = (Archiver) delegateControl.getMock();

        delegate.addFile( null, null );
        delegateControl.setMatcher( MockControl.ALWAYS_MATCHER );
        delegateControl.setVoidCallable();

        delegate.setForced( true );
        delegateControl.setVoidCallable( MockControl.ZERO_OR_MORE );

        final CounterSelector counter = new CounterSelector( true );
        final List<FileSelector> selectors = new ArrayList<FileSelector>();
        selectors.add( counter );
View Full Code Here

Examples of org.codehaus.plexus.archiver.Archiver

    @Test
    public void addDirectory_NoPerms_CallAcceptFilesOnlyOnce()
        throws IOException, ArchiverException
    {
        final Archiver delegate = new JarArchiver();

        final File output = fileManager.createTempFile();

        delegate.setDestFile( output );

        final CounterSelector counter = new CounterSelector( true );
        final List<FileSelector> selectors = new ArrayList<FileSelector>();
        selectors.add( counter );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.