Modifier and Type | Class and Description |
---|---|
static class |
ArchiveBase.Duplicate
Possible behaviors when a duplicate file is added:
"add", "preserve" or "fail"
|
static interface |
ArchiveBase.EntryBuilder
Creates an archive entry for the concrete format.
|
static interface |
ArchiveBase.FileSetBuilder
Creates an archive fileset to read the target archive.
|
static class |
ArchiveBase.Mode
Valid Modes for create/update/replace.
|
class |
ArchiveBase.ResourceCollectionFlags
Various flags a (archive) resource collection may hold.
|
class |
ArchiveBase.ResourceFlags
Various flags a (archive) resource may hold in addition to
being a plain resource.
|
class |
ArchiveBase.ResourceWithFlags
Binds a resource to additional data that may be present.
|
static class |
ArchiveBase.WhenEmpty
Possible behaviors when there are no matching files for the task:
"fail", "skip".
|
Modifier | Constructor and Description |
---|---|
protected |
ArchiveBase() |
Modifier and Type | Method and Description |
---|---|
void |
add(org.apache.tools.ant.types.ResourceCollection c)
Sources for the archive.
|
void |
addConfiguredDest(org.apache.tools.ant.types.resources.Resources r)
The archive to create.
|
protected boolean |
addDuplicate(java.lang.String name)
Is invoked if a duplicate entry is found, decides whether the
entry shall be added regardless.
|
protected java.lang.String |
bendSlashesForward(java.lang.String s)
Ensures a forward slash is used as file separator and strips
leading slashes if preserveLeadingSlashes is false.
|
protected void |
ensureParentDirs(org.apache.commons.compress.archivers.ArchiveOutputStream out,
ArchiveBase.ResourceWithFlags r,
java.util.Set directoriesAdded)
Adds records for all parent directories of the given resource
that haven't already been added.
|
void |
execute() |
protected java.util.Collection |
findSources()
Find all the resources with their flags that should be added to
the archive.
|
protected java.util.Collection |
findUnmatchedTargets(org.apache.tools.ant.types.ArchiveFileSet target,
java.util.Collection src)
Find the resources from the target archive that don't have a
matching resource in the sources to be added.
|
protected org.apache.tools.ant.types.Resource |
getDest() |
java.lang.String |
getEncoding()
Encoding of file names.
|
protected ArchiveBase.EntryBuilder |
getEntryBuilder() |
protected ArchiveStreamFactory |
getFactory() |
protected ArchiveBase.FileSetBuilder |
getFileSetBuilder() |
protected ArchiveBase.ResourceFlags |
getFlags(org.apache.tools.ant.types.Resource r)
Extracts flags from a resource.
|
protected ArchiveBase.ResourceCollectionFlags |
getFlags(org.apache.tools.ant.types.ResourceCollection rc)
Extracts flags from a resource collection.
|
protected ArchiveBase.Mode |
getMode() |
boolean |
getPreserveLeadingSlashes()
Flag to indicates whether leading `/'s should
be preserved in the file names.
|
protected boolean |
isFilesOnly()
Whether only file entries should be added to the archive.
|
protected boolean |
isUpToDate(java.util.Collection src,
org.apache.tools.ant.types.ArchiveFileSet existingEntries)
Checks whether the target is more recent than the resources
that shall be added to it.
|
protected long |
round(long millis,
long granularity)
Modify last modified timestamp based on the roundup attribute.
|
void |
setDest(org.apache.tools.ant.types.Resource r)
The archive to create.
|
void |
setDestfile(java.io.File f)
The archive to create.
|
void |
setDuplicate(ArchiveBase.Duplicate df)
Sets behavior for when a duplicate file is about to be added -
one of
add , preserve or fail . |
void |
setEncoding(java.lang.String e)
Encoding of file names.
|
protected void |
setEntryBuilder(ArchiveBase.EntryBuilder builder) |
protected void |
setFactory(ArchiveStreamFactory factory) |
protected void |
setFileSetBuilder(ArchiveBase.FileSetBuilder builder) |
void |
setFilesOnly(boolean b)
Whether only file entries should be added to the archive.
|
void |
setMode(ArchiveBase.Mode m)
How to treat the target archive.
|
void |
setPreserve0permissions(boolean b)
Whether 0 permissions read from an archive should be considered
real permissions (that should be preserved) or missing
permissions (which is the default).
|
void |
setPreserveLeadingSlashes(boolean b)
Flag to indicates whether leading `/'s should
be preserved in the file names.
|
void |
setRoundUp(boolean r)
Whether the file modification times will be rounded up to the
next timestamp (second or even second depending on the archive
format).
|
void |
setWhenempty(ArchiveBase.WhenEmpty we)
Sets behavior of the task when no resources are to be added.
|
protected void |
sort(java.util.List l)
Sorts the list of resources to add.
|
protected void |
validate()
Argument validation.
|
protected void |
writeArchive(java.util.Collection src)
Creates the archive archiving the given resources.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
protected final void setFactory(ArchiveStreamFactory factory)
protected final ArchiveStreamFactory getFactory()
protected final void setEntryBuilder(ArchiveBase.EntryBuilder builder)
protected final ArchiveBase.EntryBuilder getEntryBuilder()
protected final void setFileSetBuilder(ArchiveBase.FileSetBuilder builder)
protected final ArchiveBase.FileSetBuilder getFileSetBuilder()
public void setDestfile(java.io.File f)
public void addConfiguredDest(org.apache.tools.ant.types.resources.Resources r)
public void setDest(org.apache.tools.ant.types.Resource r)
protected org.apache.tools.ant.types.Resource getDest()
public void add(org.apache.tools.ant.types.ResourceCollection c)
public void setMode(ArchiveBase.Mode m)
protected ArchiveBase.Mode getMode()
public void setEncoding(java.lang.String e)
public java.lang.String getEncoding()
public void setFilesOnly(boolean b)
protected boolean isFilesOnly()
public void setPreserve0permissions(boolean b)
public void setRoundUp(boolean r)
Zip archives store file modification times with a granularity of two seconds, ar, tar and cpio use a granularity of one second. Times will either be rounded up or down. If you round down, the archive will always seem out-of-date when you rerun the task, so the default is to round up. Rounding up may lead to a different type of problems like JSPs inside a web archive that seem to be slightly more recent than precompiled pages, rendering precompilation useless.
r
- a boolean
valuepublic void setPreserveLeadingSlashes(boolean b)
false
.b
- the leading slashes flag.public boolean getPreserveLeadingSlashes()
public void setDuplicate(ArchiveBase.Duplicate df)
add
, preserve
or fail
.
Possible values are: add
(keep both
of the files); preserve
(keep the first version
of the file found); fail
halt a problem
Default is fail
df
- a Duplicate
enumerated valuepublic void setWhenempty(ArchiveBase.WhenEmpty we)
fail
(throw an exception
and halt the build); skip
(do not create
any archive, but issue a warning);.
Default is fail
;we
- a WhenEmpty
enumerated valuepublic void execute()
execute
in class org.apache.tools.ant.Task
protected void validate() throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
protected java.util.Collection findSources() throws java.io.IOException
java.io.IOException
protected boolean isUpToDate(java.util.Collection src, org.apache.tools.ant.types.ArchiveFileSet existingEntries) throws java.io.IOException
Will only ever be invoked if the target exists.
src
- the resources that have been found as sources, may
be modified in "update" mode to remove entries that are up to
dateexistingEntries
- the target archive as filesetjava.io.IOException
protected java.util.Collection findUnmatchedTargets(org.apache.tools.ant.types.ArchiveFileSet target, java.util.Collection src) throws java.io.IOException
java.io.IOException
protected void sort(java.util.List l)
protected void writeArchive(java.util.Collection src) throws java.io.IOException
java.io.IOException
protected void ensureParentDirs(org.apache.commons.compress.archivers.ArchiveOutputStream out, ArchiveBase.ResourceWithFlags r, java.util.Set directoriesAdded) throws java.io.IOException
Flags for the "missing" directories will be taken from the ResourceCollection that contains the resource to be added.
java.io.IOException
protected ArchiveBase.ResourceFlags getFlags(org.apache.tools.ant.types.Resource r) throws java.util.zip.ZipException
ZipExceptions are only here for the code that translates Ant's ZipExtraFields to CC ZipExtraFields and should never actually be thrown.
java.util.zip.ZipException
protected ArchiveBase.ResourceCollectionFlags getFlags(org.apache.tools.ant.types.ResourceCollection rc)
protected java.lang.String bendSlashesForward(java.lang.String s)
protected long round(long millis, long granularity)
millis
- the timestampgranularity
- the granularity of timestamps in the archive
format in millisprotected boolean addDuplicate(java.lang.String name)