Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs
Class Zip

    java.lang.Object
      |
      +--org.apache.tools.ant.Task
            |
            +--org.apache.tools.ant.taskdefs.MatchingTask
                  |
                  +--org.apache.tools.ant.taskdefs.Zip

Direct Known Subclasses:
  Jar

public class Zip
extends MatchingTask

Create a ZIP archive.

Author:
  James Davidson duncan@x180.com, Jon S. Stevens jon@clearink.com, Stefan Bodewig

Field Summary
`protected java.lang.String` | `archiveType`
`protected java.lang.String` | `emptyBehavior`

Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
`fileset, useDefaultExcludes`

Fields inherited from class org.apache.tools.ant.Task
`description, location, project, target, taskName, taskType, wrapper`

Constructor Summary
`Zip()`

Method Summary
`protected void` | `addFiles(FileScanner scanner, java.util.zip.ZipOutputStream zOut, java.lang.String prefix, java.lang.String fullpath)` Add all files of the given FileScanner to the ZipOutputStream prependig the given prefix to each filename.
`protected void` | `addFiles(java.util.Vector filesets, java.util.zip.ZipOutputStream zOut)` Iterate over the given Vector of (zip)filesets and add all files to the ZipOutputStream using the given prefix.
`void` | `addFileset(FileSet set)` Adds a set of files (nested fileset attribute).
`protected void` | `addParentDirs(java.io.File baseDir, java.lang.String entry, java.util.zip.ZipOutputStream zOut, java.lang.String prefix)` Ensure all parent dirs of a given entry have been added.
`protected void` | `addZipEntries(ZipFileSet fs, DirectoryScanner ds, java.util.zip.ZipOutputStream zOut, java.lang.String prefix)`
`void` | `addZipfileset(ZipFileSet set)` Adds a set of files (nested zipfileset attribute) that can be read from an archive and be given a prefix/fullpath.
`protected void` | `cleanUp()` Do any clean up necessary to allow this instance to be used again.
`void` | `execute()` Called by the project to let the task do it's work.
`protected static java.lang.String[][]` | `grabFileNames(FileScanner[] scanners)`
`protected static java.io.File[]` | `grabFiles(FileScanner[] scanners)`
`protected static java.io.File[]` | `grabFiles(FileScanner[] scanners, java.lang.String[][] fileNames)`
`protected void` | `initZipOutputStream(java.util.zip.ZipOutputStream zOut)`
`protected boolean` | `isUpToDate(FileScanner[] scanners, java.io.File zipFile)` Check whether the archive is up-to-date; and handle behavior for empty archives.
`void` | `setBasedir(java.io.File baseDir)` This is the base directory to look in for things to zip.
`void` | `setCompress(boolean c)` Sets whether we want to compress the files or only store them.
`void` | `setWhenempty(java.lang.String we)` Sets behavior of the task when no files match.
`void` | `setZipfile(java.io.File zipFile)` This is the name/location of where to create the .zip file.
`protected void` | `zipDir(java.io.File dir, java.util.zip.ZipOutputStream zOut, java.lang.String vPath)`
`protected void` | `zipFile(java.io.File file, java.util.zip.ZipOutputStream zOut, java.lang.String vPath)`
`protected void` | `zipFile(java.io.InputStream in, java.util.zip.ZipOutputStream zOut, java.lang.String vPath, long lastModified)`

Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
`createExclude, createInclude, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems`

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getProject, getRuntimeConfigurableWrapper, getTaskName, init, log, log, maybeConfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### archiveType

    protected java.lang.String archiveType

### emptyBehavior

    protected java.lang.String emptyBehavior

Constructor Detail

### Zip

    public Zip()

Method Detail

### setZipfile

    public void setZipfile(java.io.File zipFile)

  This is the name/location of where to create the .zip file.

### setBasedir

    public void setBasedir(java.io.File baseDir)

  This is the base directory to look in for things to zip.

### setCompress

    public void setCompress(boolean c)

  Sets whether we want to compress the files or only store them.

### addFileset

    public void addFileset(FileSet set)

  Adds a set of files (nested fileset attribute).

### addZipfileset

    public void addZipfileset(ZipFileSet set)

  Adds a set of files (nested zipfileset attribute) that can be read from an archive and be given a prefix/fullpath.

### setWhenempty

    public void setWhenempty(java.lang.String we)
                      throws BuildException

  Sets behavior of the task when no files match. Possible values are: `fail` (throw an exception and halt the build); `skip` (do not create any archive, but issue a warning); `create` (make an archive with no entries). Default for zip tasks is `skip`; for jar tasks, `create`.

### execute

    public void execute()
                 throws BuildException

  Description copied from class: `Task`
  Called by the project to let the task do it's work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.
  Overrides:
    `execute` in class `Task`
  Following copied from class: `org.apache.tools.ant.Task`
  Throws:
    `BuildException` - if someting goes wrong with the build

### addFiles

    protected void addFiles(FileScanner scanner,
                            java.util.zip.ZipOutputStream zOut,
                            java.lang.String prefix,
                            java.lang.String fullpath)
                     throws java.io.IOException

  Add all files of the given FileScanner to the ZipOutputStream prependig the given prefix to each filename.

  Ensure parent directories have been added as well.

### addZipEntries

    protected void addZipEntries(ZipFileSet fs,
                                 DirectoryScanner ds,
                                 java.util.zip.ZipOutputStream zOut,
                                 java.lang.String prefix)
                          throws java.io.IOException

### initZipOutputStream

    protected void initZipOutputStream(java.util.zip.ZipOutputStream zOut)
                                throws java.io.IOException,
                                       BuildException

### isUpToDate

    protected boolean isUpToDate(FileScanner[] scanners,
                                 java.io.File zipFile)
                          throws BuildException

  Check whether the archive is up-to-date; and handle behavior for empty archives.
  Parameters:
    `scanners` - list of prepared scanners containing files to archive
    `zipFile` - intended archive file (may or may not exist)
  Returns:
    true if nothing need be done (may have done something already); false if archive creation should proceed
  Throws:
    `BuildException` - if it likes

### grabFiles

    protected static java.io.File[] grabFiles(FileScanner[] scanners)

### grabFiles

    protected static java.io.File[] grabFiles(FileScanner[] scanners,
                                              java.lang.String[][] fileNames)

### grabFileNames

    protected static java.lang.String[][] grabFileNames(FileScanner[] scanners)

### zipDir

    protected void zipDir(java.io.File dir,
                          java.util.zip.ZipOutputStream zOut,
                          java.lang.String vPath)
                   throws java.io.IOException

### zipFile

    protected void zipFile(java.io.InputStream in,
                           java.util.zip.ZipOutputStream zOut,
                           java.lang.String vPath,
                           long lastModified)
                    throws java.io.IOException

### zipFile

    protected void zipFile(java.io.File file,
                           java.util.zip.ZipOutputStream zOut,
                           java.lang.String vPath)
                    throws java.io.IOException

### addParentDirs

    protected void addParentDirs(java.io.File baseDir,
                                 java.lang.String entry,
                                 java.util.zip.ZipOutputStream zOut,
                                 java.lang.String prefix)
                          throws java.io.IOException

  Ensure all parent dirs of a given entry have been added.

### addFiles

    protected void addFiles(java.util.Vector filesets,
                            java.util.zip.ZipOutputStream zOut)
                     throws java.io.IOException

  Iterate over the given Vector of (zip)filesets and add all files to the ZipOutputStream using the given prefix.

### cleanUp

    protected void cleanUp()

  Do any clean up necessary to allow this instance to be used again.

  When we get here, the Zip file has been closed and all we need to do is to reset some globals.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 Apache Software Foundation. All Rights Reserved.