public abstract class AbstractZipArchiver extends AbstractArchiver
Modifier and Type | Field and Description |
---|---|
protected AddedDirs |
addedDirs |
protected boolean |
addingNewFiles
true when we are adding new files into the Zip file, as opposed
to adding back the unchanged files
|
protected String |
archiveType |
protected boolean |
doubleFilePass |
protected String |
duplicate
Deprecated.
Use
Archiver.setDuplicateBehavior(String) instead. |
protected Hashtable<String,String> |
entries |
protected boolean |
skipWriting |
protected org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream |
zipArchiveOutputStream |
DEFAULT_DIR_MODE, DEFAULT_FILE_MODE, DEFAULT_SYMLILNK_MODE, DUPLICATES_ADD, DUPLICATES_FAIL, DUPLICATES_PRESERVE, DUPLICATES_SKIP, DUPLICATES_VALID_BEHAVIORS, ROLE
Constructor and Description |
---|
AbstractZipArchiver() |
Modifier and Type | Method and Description |
---|---|
protected void |
addResources(ResourceIterator resources,
ConcurrentJarCreator zOut)
Add the given resources.
|
protected void |
cleanUp()
Do any clean up necessary to allow this instance to be used again.
|
protected void |
close() |
protected boolean |
createEmptyZip(File zipFile)
Create an empty zip file
|
protected void |
execute() |
protected void |
finalizeZipOutputStream(ConcurrentJarCreator zOut) |
protected String |
getArchiveType() |
String |
getComment() |
String |
getEncoding() |
protected void |
initZipOutputStream(ConcurrentJarCreator zOut)
method for subclasses to override
|
boolean |
isCompress() |
boolean |
isFilesonly() |
boolean |
isInUpdateMode() |
boolean |
isRecompressAddedZips() |
boolean |
isSupportingForced()
method for subclasses to override
|
protected FileTime |
normalizeLastModifiedTime(FileTime lastModifiedTime)
Normalize last modified time value to get reproducible archive entries, based on
archive binary format.
|
void |
reset()
Makes this instance reset all attributes to their default
values and forget all children.
|
protected boolean |
revert(StringBuffer messageBuffer) |
void |
setComment(String comment) |
void |
setCompress(boolean compress) |
void |
setEncoding(String encoding) |
void |
setFilesonly(boolean f)
If true, emulate Sun's jar utility by not adding parent directories;
optional, defaults to false.
|
void |
setRecompressAddedZips(boolean recompressAddedZips) |
void |
setUpdateMode(boolean update) |
protected void |
setZipEntryTime(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipEntry,
long lastModifiedTime)
Set the ZipEntry dostime using the date if specified otherwise the original time.
|
protected void |
zipDir(org.codehaus.plexus.components.io.resources.PlexusIoResource dir,
ConcurrentJarCreator zOut,
String vPath,
int mode,
String encodingToUse) |
protected void |
zipFile(ArchiveEntry entry,
ConcurrentJarCreator zOut,
String vPath)
Method that gets called when adding from java.io.File instances.
|
protected void |
zipFile(org.apache.commons.compress.parallel.InputStreamSupplier in,
ConcurrentJarCreator zOut,
String vPath,
long lastModified,
File fromArchive,
int mode,
String symlinkDestination,
boolean addInParallel)
Adds a new entry to the archive, takes care of duplicates as well.
|
addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchiveFinalizer, addDirectory, addDirectory, addDirectory, addDirectory, addFile, addFile, addFileSet, addResource, addResources, addSymlink, addSymlink, asArchiveEntry, asResourceCollection, checkForced, configureReproducible, configureReproducibleBuild, contextualize, createArchive, getDefaultDirectoryMode, getDefaultFileMode, getDestFile, getDirectoryMode, getDuplicateBehavior, getFileMode, getFilenameComparator, getFiles, getIncludeEmptyDirs, getLastModifiedDate, getLastModifiedTime, getLogger, getOverrideDirectoryMode, getOverrideFileMode, getOverrideGid, getOverrideGroupName, getOverrideUid, getOverrideUserName, getRawDefaultFileMode, getResources, hasVirtualFiles, isForced, isIgnorePermissions, isUptodate, isUseJvmChmod, postCreateArchive, runArchiveFinalizers, setArchiveFinalizers, setDefaultDirectoryMode, setDefaultFileMode, setDestFile, setDirectoryMode, setDotFileDirectory, setDuplicateBehavior, setFileMode, setFilenameComparator, setForced, setIgnorePermissions, setIncludeEmptyDirs, setLastModifiedDate, setLastModifiedTime, setOverrideGid, setOverrideGroupName, setOverrideUid, setOverrideUserName, setUseJvmChmod, validate
protected String archiveType
protected final AddedDirs addedDirs
protected boolean doubleFilePass
protected boolean skipWriting
@Deprecated protected final String duplicate
Archiver.setDuplicateBehavior(String)
instead.protected boolean addingNewFiles
protected org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zipArchiveOutputStream
public String getComment()
public void setComment(String comment)
public String getEncoding()
public void setEncoding(String encoding)
public void setCompress(boolean compress)
public boolean isCompress()
public boolean isRecompressAddedZips()
public void setRecompressAddedZips(boolean recompressAddedZips)
public void setUpdateMode(boolean update)
public boolean isInUpdateMode()
public void setFilesonly(boolean f)
f
- true to emilate sun jar utilitypublic boolean isFilesonly()
protected void execute() throws ArchiverException, IOException
execute
in class AbstractArchiver
ArchiverException
IOException
protected void finalizeZipOutputStream(ConcurrentJarCreator zOut) throws IOException, ArchiverException
IOException
ArchiverException
protected final void addResources(ResourceIterator resources, ConcurrentJarCreator zOut) throws IOException, ArchiverException
resources
- the resources to addzOut
- the stream to write toIOException
ArchiverException
protected void zipFile(org.apache.commons.compress.parallel.InputStreamSupplier in, ConcurrentJarCreator zOut, String vPath, long lastModified, File fromArchive, int mode, String symlinkDestination, boolean addInParallel) throws IOException, ArchiverException
in
- the stream to read data for the entry from.zOut
- the stream to write to.vPath
- the name this entry shall have in the archive.lastModified
- last modification time for the entry.fromArchive
- the original archive we are copying thissymlinkDestination
- addInParallel
- Indicates if the entry should be add in parallel.
If set to false
it is added synchronously.
If the entry is symbolic link this parameter is ignored.IOException
ArchiverException
protected void zipFile(ArchiveEntry entry, ConcurrentJarCreator zOut, String vPath) throws IOException, ArchiverException
This implementation delegates to the six-arg version.
entry
- the file to add to the archivezOut
- the stream to write tovPath
- the name this entry shall have in the archiveIOException
ArchiverException
protected void setZipEntryTime(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipEntry, long lastModifiedTime)
Zip archives store file modification times with a granularity of two seconds, so the 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. plexus-archiver chooses to round up.
zipEntry
- to set the last modified timelastModifiedTime
- to set in the zip entry only if AbstractArchiver.getLastModifiedTime()
returns nullprotected void zipDir(org.codehaus.plexus.components.io.resources.PlexusIoResource dir, ConcurrentJarCreator zOut, String vPath, int mode, String encodingToUse) throws IOException
IOException
protected boolean createEmptyZip(File zipFile) throws ArchiverException
zipFile
- The fileArchiverException
protected void cleanUp() throws IOException
When we get here, the Zip file has been closed and all we need to do is to reset some globals.
This method will only reset globals that have been changed during execute(), it will not alter the attributes or nested child elements. If you want to reset the instance so that you can later zip a completely different set of files, you must use the reset method.
cleanUp
in class AbstractArchiver
IOException
reset()
public void reset()
cleanUp()
protected void initZipOutputStream(ConcurrentJarCreator zOut) throws ArchiverException, IOException
zOut
- The output streamArchiverException
IOException
public boolean isSupportingForced()
isSupportingForced
in interface Archiver
isSupportingForced
in class AbstractArchiver
Archiver.setForced(boolean)
,
Archiver.isForced()
protected boolean revert(StringBuffer messageBuffer)
revert
in class AbstractArchiver
protected void close() throws IOException
close
in class AbstractArchiver
IOException
protected String getArchiveType()
getArchiveType
in class AbstractArchiver
protected FileTime normalizeLastModifiedTime(FileTime lastModifiedTime)
AbstractArchiver
tar uses UTC timestamp, but zip uses local time then requires tweaks to make the value reproducible whatever the current timezone is.
normalizeLastModifiedTime
in class AbstractArchiver
lastModifiedTime
- The last modification timeAbstractArchiver.configureReproducibleBuild(FileTime)
Copyright © 2001–2022 Codehaus Plexus. All rights reserved.