Package org.codehaus.plexus.archiver.zip

Examples of org.codehaus.plexus.archiver.zip.ZipFile


    getLog().info("Creating Jangaroo application script '" + f.getAbsolutePath() + "'.");
    return new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
  }

  private void includeJangarooModuleScript(File scriptDirectory, Artifact artifact, Writer jangarooApplicationWriter, Writer jangarooApplicationAllWriter) throws IOException {
    ZipFile zipFile = new ZipFile(artifact.getFile());
    ZipEntry zipEntry = zipFile.getEntry(computeModuleJsFileName(artifact.getArtifactId()));
    ModuleSource jooModuleSource = zipEntry != null ? new ZipEntryModuleSource(zipFile, zipEntry) : null;
    writeJangarooModuleScript(scriptDirectory, artifact, jooModuleSource, jangarooApplicationWriter, jangarooApplicationAllWriter);
  }
View Full Code Here


   */
  private boolean ignoreVersioned;


  private String getThemeDescriptor(final File jarFile) throws MojoExecutionException {
    ZipFile zip = null;
    try {
      zip = new ZipFile(jarFile);
      final Enumeration files = zip.getEntries();
      while (files.hasMoreElements()) {
        final ZipEntry nextEntry = (ZipEntry) files.nextElement();
        if (nextEntry == null || nextEntry.isDirectory()) {
          continue;
        }
        final String name = nextEntry.getName();
        if (name.equals("META-INF/tobago-theme.xml") || name.equals("META-INF/tobago-config.xml")) {
          XmlStreamReader xsr = null;
          try {
            final StringWriter stringWriter = new StringWriter();
            xsr = ReaderFactory.newXmlReader(zip.getInputStream(nextEntry));
            IOUtil.copy(xsr, stringWriter);
            return stringWriter.toString();
          } finally {
            IOUtil.close(xsr);
          }
        }
      }
    } catch (final IOException e) {
      throw new MojoExecutionException("Error find ThemeDescriptor in " + jarFile, e);
    } finally {
      if (zip != null) {
        try {
          zip.close();
        } catch (final IOException e) {
          // ignore
        }
      }
    }
View Full Code Here

     */
    protected static final void grabFilesAndDirs( String file, List dirs,
                                                  List files )
        throws IOException
    {
        ZipFile zf = null;
        try
        {
            zf = new ZipFile( file, "utf-8" );
            Enumeration entries = zf.getEntries();
            HashSet dirSet = new HashSet();
            while ( entries.hasMoreElements() )
            {
                ZipEntry ze =
                    (ZipEntry) entries.nextElement();
                String name = ze.getName();
                // avoid index for manifest-only jars.
                if (!name.equals(META_INF_NAME) && !name.equals(META_INF_NAME+"/") &&
                        !name.equals(INDEX_NAME) && !name.equals(MANIFEST_NAME))
                {
                    if ( ze.isDirectory() )
                    {
                        dirSet.add( name );
                    }
                    else if ( name.indexOf( "/" ) == -1 )
                    {
                        files.add( name );
                    }
                    else
                    {
                        // a file, not in the root
                        // since the jar may be one without directory
                        // entries, add the parent dir of this file as
                        // well.
                        dirSet.add( name.substring( 0,
                                                    name.lastIndexOf( "/" ) + 1 ) );
                    }
                }
            }
            dirs.addAll( dirSet );
        }
        finally
        {
            if ( zf != null )
            {
                zf.close();
            }
        }
    }
View Full Code Here

        File generatedFile =
            new File( getBasedir(), "target/test/unit/javadocjar-default/target/javadocjar-default-javadoc.jar" );
        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );

        //validate contents of jar file
        ZipFile jar = new ZipFile( generatedFile );
        Set<String> set = new HashSet<String>();
        for( Enumeration<ZipEntry> entries = jar.getEntries(); entries.hasMoreElements(); )
        {
            ZipEntry entry = entries.nextElement();
            set.add( entry.getName() );
        }
View Full Code Here

        expectedFiles.add( "META-INF/" );
        expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" );
        expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" );
        expectedFiles.add( "test-eba.jar" );

        ZipFile eba = new ZipFile( ebaFile );

        Enumeration entries = eba.getEntries();

        assertTrue( entries.hasMoreElements() );

        assertTrue( entries.hasMoreElements() );
View Full Code Here

        expectedFiles.add( "META-INF/APPLICATION.MF" );
        expectedFiles.add( "META-INF/" );
        expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" );
        expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" );

        ZipFile eba = new ZipFile( ebaFile );

        Enumeration entries = eba.getEntries();

        assertTrue( entries.hasMoreElements() );

        assertTrue( entries.hasMoreElements() );
View Full Code Here

        expectedFiles.add( "META-INF/APPLICATION.MF" );
        expectedFiles.add( "META-INF/" );
        expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" );
        expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" );

        ZipFile eba = new ZipFile( ebaFile );

        Enumeration entries = eba.getEntries();

        assertTrue( entries.hasMoreElements() );

        int missing = getSizeOfExpectedFiles(entries, expectedFiles);
        assertEquals("Missing files: " + expectedFiles,  0, missing);
View Full Code Here

        File generatedFile =
            new File( getBasedir(), "target/test/unit/javadocjar-default/target/javadocjar-default-javadoc.jar" );
        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );

        //validate contents of jar file
        ZipFile jar = new ZipFile( generatedFile );
        Set<String> set = new HashSet<String>();
        for( Enumeration<ZipEntry> entries = jar.getEntries(); entries.hasMoreElements(); )
        {
            ZipEntry entry = entries.nextElement();
            set.add( entry.getName() );
        }
View Full Code Here

     */
    protected static final void grabFilesAndDirs( String file, List dirs,
                                                  List files )
        throws IOException
    {
        ZipFile zf = null;
        try
        {
            zf = new ZipFile( file, "utf-8" );
            Enumeration entries = zf.getEntries();
            HashSet dirSet = new HashSet();
            while ( entries.hasMoreElements() )
            {
                ZipEntry ze =
                    (ZipEntry) entries.nextElement();
                String name = ze.getName();
                // META-INF would be skipped anyway, avoid index for
                // manifest-only jars.
                if ( !name.startsWith( "META-INF/" ) )
                {
                    if ( ze.isDirectory() )
                    {
                        dirSet.add( name );
                    }
                    else if ( name.indexOf( "/" ) == -1 )
                    {
                        files.add( name );
                    }
                    else
                    {
                        // a file, not in the root
                        // since the jar may be one without directory
                        // entries, add the parent dir of this file as
                        // well.
                        dirSet.add( name.substring( 0,
                                                    name.lastIndexOf( "/" ) + 1 ) );
                    }
                }
            }
            dirs.addAll( dirSet );
        }
        finally
        {
            if ( zf != null )
            {
                zf.close();
            }
        }
    }
View Full Code Here

     */
    protected static final void grabFilesAndDirs( String file, List dirs,
                                                  List files )
        throws IOException
    {
        ZipFile zf = null;
        try
        {
            zf = new ZipFile( file, "utf-8" );
            Enumeration entries = zf.getEntries();
            HashSet dirSet = new HashSet();
            while ( entries.hasMoreElements() )
            {
                ZipEntry ze =
                    (ZipEntry) entries.nextElement();
                String name = ze.getName();
                // avoid index for manifest-only jars.
                if (!name.equals(META_INF_NAME) && !name.equals(META_INF_NAME+"/") &&
                        !name.equals(INDEX_NAME) && !name.equals(MANIFEST_NAME))
                {
                    if ( ze.isDirectory() )
                    {
                        dirSet.add( name );
                    }
                    else if ( name.indexOf( "/" ) == -1 )
                    {
                        files.add( name );
                    }
                    else
                    {
                        // a file, not in the root
                        // since the jar may be one without directory
                        // entries, add the parent dir of this file as
                        // well.
                        dirSet.add( name.substring( 0,
                                                    name.lastIndexOf( "/" ) + 1 ) );
                    }
                }
            }
            dirs.addAll( dirSet );
        }
        finally
        {
            if ( zf != null )
            {
                zf.close();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.zip.ZipFile

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.