Build a Zip archive.
Task package: | org.schmant.task.base |
Java package: | org.schmant.task.io.zip |
Category: | Archiving tasks |
Since: | 0.5 |
EntityFS-aware? | Yes* |
Implements: | ActionTaskFactory GeneratorTaskFactory ProcessTaskFactory |
Produces: | EFile (the target property). |
See also: | At4JZipTF At4JUnzipTF |
Description:
Build a new Zip archive.
This task uses Java's built-in Zip classes, and is thus somewhat limited in functionality. The files are always stored in the archive using the MSDOS file system type. This makes it impossible to, for instance, set Unix permissions on them. The At4JZipTF task is more flexible in how it can configure the Zip files that it builds.
Appending to existing archives is not supported.
Required properties
Properties
comment | top |
The Zip file comment.
- Setter method:
setComment(String s)
Set the comment.parameters:s
– The comment.- Default value:
- Created by Schmant -- www.schmant.org
entryInfoProvider | top |
A provider for extra Zip entry information for each entry (file or directory) in the archive.
- Setter method:
setExtraInfoProvider(ZipEntryInfoProvider p)
Set the providerparameters:p
– The provider.
level | top |
The compression level for entries added to the archive. The level is represented as an integer between 0 (no compression) and 9 (best compression).
- Setter method:
setLevel(int l)
Set the compression levelparameters:l
– The level (0-9).- Default value:
- The default compression level of the Zlib library. Currently 6, but that may change in the future.
logFooter | top |
The message that is logged to info
level
after the task has been successfully run.
- Setter method:
setLogFooter(String s)
parameters:s
– The footer message.- Default value:
- Empty (no footer message is logged.)
- See also:
- logHeader
logHeader | top |
The message that is logged to info
level
before the task is run.
- Setter method:
setLogHeader(String s)
parameters:s
– The header message.- Default value:
- A task class specific message.
- See also:
- logFooter
method | top |
The compression method for entities added to the archive.
- Setter method:
setMethod(ZipCompressionMethod m)
Set the compression method represented by aparameters:ZipCompressionMethod
enum.m
– AZipCompressionMethod
representing the compression method. This is one of- DEFLATED
- FILTERED
- HUFFMAN_ONLY
- NO_COMPRESSION
- Setter method:
setMethod(int i)
Set the compression method represented by one of theparameters:Deflater
constants.- Default value:
- DEFLATED
overwriteStrategy | top |
The overwrite strategy decides how the task will react if there already is an entity (file or directory) in a location where it wants to create a new entity.
If the strategy is to not overwrite existing entities, the task will fail when it cannot create the entities that it wants to create.
Non-empty directories are never overwritten, regardless of the chosen strategy.
- Setter method:
setOverwrite(boolean b)
Setting this to a value ofparameters:true
means that the DoOverwriteAndLogWarning strategy is used. A value of false gives the DontOverwriteAndThrowException strategy.b
– Should an existing entity be overwritten?- Setter method:
setOverwriteStrategy(OverwriteStrategy strat)
Set the overwrite strategy.parameters:strat
– The overwrite strategy.- Default value:
- DontOverwriteAndThrowException
- See also:
- target
reportLevel | top |
This property is used to change the Report level for all task created by this task factory. The report level is changed for the thread running the task when the it is run, and is restored to its previous level when the it is done.
- Setter method:
setReportLevel(Level l)
Set the report levelparameters:l
– The new report level.
sources (required) | top |
A collection of sources that are added to the Zip archive by the task.
Each source can be set with or without locations relative to a base path. If the entities are added with a base path, they are stored under that path in the Zip archive.
See the interpreter documentation and the examples below for more information.
- Setter method:
addSource(Object o)
Add one or several sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byAbstractJavaZipTask.createIterator()
.- Setter method:
addSources(Object o)
Add one or several sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byAbstractJavaZipTask.createIterator()
.- Setter method:
clearSources()
Discard all sources.- Setter method:
setSource(Object o)
Set one or several sources and discard previously set sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byAbstractJavaZipTask.createIterator()
.- Setter method:
setSources(Object o)
Set one or several sources and discard previously set sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byAbstractJavaZipTask.createIterator()
.
target (required) | top |
The Zip file to create.
- Setter method:
setTarget(Object o)
parameters:
traceLogging | top |
If trace logging is enabled for a task, it reports its configuration before it is run.
Trace logging may also be enabled globally for all tasks by calling TraceMode.setTraceMode(boolean).
- Setter method:
setTraceLogging(boolean b)
Enable or disable trace logging.parameters:b
– Enable trace logging?
Examples
Example 1
Create a Zip archive from the contents of directory
hierarchies d1
and d2
, both stored under the directory
ds-1.0
in the Zip file. The archive will be put in the directory
d
.
JavaScript
Example 2
Create a Zip archive from the contents of directory
hierarchies d1
and d2
, ignoring all .svn
directories. Both directory hierarchies are stored under the directory
ds-1.0
in the Zip file. The archive will be put in the directory
d
.
JavaScript
Example 3
Create a Zip archive with the sources set in many
different ways. The archive will be put in the directory d
.
Groovy
JavaScript
JRuby
Jython
* An EntityFS-aware task is implemented using EntityFS. This means that it uses the filter settings of DirectoryView:s and also that it often can work with other file system implementations than File-based, such as the RAM file system.