|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.ProjectComponent | +--org.apache.tools.ant.Task | +--org.apache.tools.ant.taskdefs.MatchingTask | +--org.apache.tools.ant.taskdefs.Zip
Create a ZIP archive.
Inner Class Summary | |
static class |
Zip.WhenEmpty
Possible behaviors when there are no matching files for the task. |
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, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
project |
Constructor Summary | |
Zip()
|
Method Summary | |
protected void |
addFiles(FileScanner scanner,
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,
ZipOutputStream zOut)
Iterate over the given Vector of (zip)filesets and add all files to the ZipOutputStream using the given prefix or fullpath. |
void |
addFileset(FileSet set)
Adds a set of files (nested fileset attribute). |
protected void |
addParentDirs(java.io.File baseDir,
java.lang.String entry,
ZipOutputStream zOut,
java.lang.String prefix)
Ensure all parent dirs of a given entry have been added. |
protected void |
addZipEntries(ZipFileSet fs,
DirectoryScanner ds,
ZipOutputStream zOut,
java.lang.String prefix,
java.lang.String fullpath)
|
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. |
protected boolean |
createEmptyZip(java.io.File zipFile)
Create an empty zip file |
void |
execute()
Called by the project to let the task do it's work. |
protected void |
finalizeZipOutputStream(ZipOutputStream zOut)
|
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(ZipOutputStream zOut)
|
protected boolean |
isAddingNewFiles()
Indicates if the task is adding new files into the archive as opposed to copying back unchanged files from the backup copy |
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 |
setEncoding(java.lang.String encoding)
Encoding to use for filenames, defaults to the platform's default encoding. |
void |
setFilesonly(boolean f)
Emulate Sun's jar utility by not adding parent dirs |
void |
setUpdate(boolean c)
Sets whether we want to update the file (if it exists) or create a new one. |
void |
setWhenempty(Zip.WhenEmpty 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,
ZipOutputStream zOut,
java.lang.String vPath)
|
protected void |
zipFile(java.io.File file,
ZipOutputStream zOut,
java.lang.String vPath)
|
protected void |
zipFile(java.io.InputStream in,
ZipOutputStream zOut,
java.lang.String vPath,
long lastModified)
|
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
getProject, setProject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String archiveType
protected java.lang.String emptyBehavior
Constructor Detail |
public Zip()
Method Detail |
public void setZipfile(java.io.File zipFile)
public void setBasedir(java.io.File baseDir)
public void setCompress(boolean c)
public void setFilesonly(boolean f)
public void setUpdate(boolean c)
public void addFileset(FileSet set)
public void addZipfileset(ZipFileSet set)
public void setWhenempty(Zip.WhenEmpty we)
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
.public void setEncoding(java.lang.String encoding)
For a list of possible values see http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html.
public void execute() throws BuildException
Task
execute
in class Task
org.apache.tools.ant.Task
BuildException
- if someting goes wrong with the buildprotected boolean isAddingNewFiles()
protected void addFiles(FileScanner scanner, ZipOutputStream zOut, java.lang.String prefix, java.lang.String fullpath) throws java.io.IOException
Ensure parent directories have been added as well.
protected void addZipEntries(ZipFileSet fs, DirectoryScanner ds, ZipOutputStream zOut, java.lang.String prefix, java.lang.String fullpath) throws java.io.IOException
protected void initZipOutputStream(ZipOutputStream zOut) throws java.io.IOException, BuildException
protected void finalizeZipOutputStream(ZipOutputStream zOut) throws java.io.IOException, BuildException
protected boolean createEmptyZip(java.io.File zipFile)
protected boolean isUpToDate(FileScanner[] scanners, java.io.File zipFile) throws BuildException
scanners
- list of prepared scanners containing files to archivezipFile
- intended archive file (may or may not exist)BuildException
- if it likesprotected static java.io.File[] grabFiles(FileScanner[] scanners)
protected static java.io.File[] grabFiles(FileScanner[] scanners, java.lang.String[][] fileNames)
protected static java.lang.String[][] grabFileNames(FileScanner[] scanners)
protected void zipDir(java.io.File dir, ZipOutputStream zOut, java.lang.String vPath) throws java.io.IOException
protected void zipFile(java.io.InputStream in, ZipOutputStream zOut, java.lang.String vPath, long lastModified) throws java.io.IOException
protected void zipFile(java.io.File file, ZipOutputStream zOut, java.lang.String vPath) throws java.io.IOException
protected void addParentDirs(java.io.File baseDir, java.lang.String entry, ZipOutputStream zOut, java.lang.String prefix) throws java.io.IOException
protected void addFiles(java.util.Vector filesets, ZipOutputStream zOut) throws java.io.IOException
protected void cleanUp()
When we get here, the Zip file has been closed and all we need to do is to reset some globals.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |