public abstract class AbstractArchiver extends org.codehaus.plexus.logging.AbstractLogEnabled implements Archiver, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable, FinalizerEnabled
DEFAULT_DIR_MODE, DEFAULT_FILE_MODE, DEFAULT_SYMLILNK_MODE, DUPLICATES_ADD, DUPLICATES_FAIL, DUPLICATES_PRESERVE, DUPLICATES_SKIP, DUPLICATES_VALID_BEHAVIORS, ROLE
Constructor and Description |
---|
AbstractArchiver() |
Modifier and Type | Method and Description |
---|---|
void |
addArchivedFileSet(ArchivedFileSet fileSet)
Adds the given archive file set to the archive.
|
void |
addArchivedFileSet(ArchivedFileSet fileSet,
Charset charset)
Adds the given archive file set to the archive.
|
void |
addArchivedFileSet(File archiveFile)
Obsolete, use
Archiver.addArchivedFileSet(ArchivedFileSet) . |
void |
addArchivedFileSet(File archiveFile,
String prefix)
Obsolete, use
Archiver.addArchivedFileSet(ArchivedFileSet) . |
void |
addArchivedFileSet(File archiveFile,
String[] includes,
String[] excludes)
Obsolete, use
Archiver.addArchivedFileSet(ArchivedFileSet) . |
void |
addArchivedFileSet(File archiveFile,
String prefix,
String[] includes,
String[] excludes)
Obsolete, use
Archiver.addArchivedFileSet(ArchivedFileSet) . |
void |
addArchiveFinalizer(ArchiveFinalizer finalizer) |
void |
addDirectory(File directory)
Obsolete, use
Archiver.addFileSet(FileSet) . |
void |
addDirectory(File directory,
String prefix)
Obsolete, use
Archiver.addFileSet(FileSet) . |
void |
addDirectory(File directory,
String[] includes,
String[] excludes)
Obsolete, use
Archiver.addFileSet(FileSet) . |
void |
addDirectory(File directory,
String prefix,
String[] includes,
String[] excludes)
Obsolete, use
Archiver.addFileSet(FileSet) . |
void |
addFile(File inputFile,
String destFileName) |
void |
addFile(File inputFile,
String destFileName,
int permissions) |
void |
addFileSet(FileSet fileSet)
Adds the given file set to the archive.
|
void |
addResource(org.codehaus.plexus.components.io.resources.PlexusIoResource resource,
String destFileName,
int permissions)
Adds the given resource collection to the archive.
|
void |
addResources(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection)
Adds a resource collection to the archive.
|
void |
addSymlink(String symlinkName,
int permissions,
String symlinkDestination) |
void |
addSymlink(String symlinkName,
String symlinkDestination) |
protected ArchiveEntry |
asArchiveEntry(org.codehaus.plexus.components.io.resources.PlexusIoResource resource,
String destFileName,
int permissions,
org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection) |
protected org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection |
asResourceCollection(ArchivedFileSet fileSet,
Charset charset) |
protected boolean |
checkForced() |
protected void |
cleanUp() |
protected abstract void |
close() |
void |
configureReproducible(Date lastModifiedDate)
Deprecated.
Use
configureReproducibleBuild(FileTime) instead. |
void |
configureReproducibleBuild(FileTime lastModifiedTime)
Configure the archiver to create archives in a reproducible way (see
Reproducible Builds).
|
void |
contextualize(org.codehaus.plexus.context.Context context)
Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg
instantiation/composition problem.
|
void |
createArchive() |
protected abstract void |
execute() |
protected abstract String |
getArchiveType() |
int |
getDefaultDirectoryMode() |
int |
getDefaultFileMode() |
File |
getDestFile() |
int |
getDirectoryMode()
Gets the forced mode for directories, falling back to default if none is forced.
|
String |
getDuplicateBehavior()
Returns the behavior of this archiver when duplicate files are detected.
|
int |
getFileMode() |
Comparator<String> |
getFilenameComparator() |
Map<String,ArchiveEntry> |
getFiles() |
boolean |
getIncludeEmptyDirs() |
Date |
getLastModifiedDate()
Deprecated.
Use
getLastModifiedTime() instead. |
FileTime |
getLastModifiedTime()
Returns the last modification time of the archiver.
|
protected org.codehaus.plexus.logging.Logger |
getLogger() |
int |
getOverrideDirectoryMode() |
int |
getOverrideFileMode() |
int |
getOverrideGid() |
String |
getOverrideGroupName() |
int |
getOverrideUid() |
String |
getOverrideUserName() |
int |
getRawDefaultFileMode()
Deprecated.
|
ResourceIterator |
getResources()
Returns an iterator over instances of
ArchiveEntry , which have previously been added by calls to
Archiver.addResources(PlexusIoResourceCollection) , Archiver.addResource(PlexusIoResource, String, int) ,
Archiver.addFileSet(FileSet) , etc. |
protected boolean |
hasVirtualFiles() |
boolean |
isForced()
Returns, whether recreating the archive is forced (default).
|
boolean |
isIgnorePermissions() |
boolean |
isSupportingForced()
Returns, whether the archive supports uptodate checks.
|
protected boolean |
isUptodate() |
boolean |
isUseJvmChmod() |
protected FileTime |
normalizeLastModifiedTime(FileTime lastModifiedTime)
Normalize last modified time value to get reproducible archive entries, based on
archive binary format.
|
protected void |
postCreateArchive()
This method is called after the archive creation
completes successfully (no exceptions are thrown).
|
protected boolean |
revert(StringBuffer messageBuffer) |
protected void |
runArchiveFinalizers() |
void |
setArchiveFinalizers(List<ArchiveFinalizer> archiveFinalizers) |
void |
setDefaultDirectoryMode(int mode)
This is the "default" value we should use if no other value is specified
|
void |
setDefaultFileMode(int mode) |
void |
setDestFile(File destFile) |
void |
setDirectoryMode(int mode)
This is the forced mode that should be used regardless if set, otherwise falls back to default.
|
void |
setDotFileDirectory(File dotFileDirectory) |
void |
setDuplicateBehavior(String duplicate)
Set the behavior of this archiver when duplicate files are detected.
|
void |
setFileMode(int mode) |
void |
setFilenameComparator(Comparator<String> filenameComparator)
Set filename comparator, used to sort file entries when scanning directories since File.list() does not
guarantee any order.
|
void |
setForced(boolean forced)
Sets, whether recreating the archive is forced (default).
|
void |
setIgnorePermissions(boolean ignorePermissions) |
void |
setIncludeEmptyDirs(boolean includeEmptyDirs) |
void |
setLastModifiedDate(Date lastModifiedDate)
Deprecated.
Use
setLastModifiedTime(FileTime) instead. |
void |
setLastModifiedTime(FileTime lastModifiedTime)
Sets the last modification time of the entries (if non null).
|
void |
setOverrideGid(int gid) |
void |
setOverrideGroupName(String groupName) |
void |
setOverrideUid(int uid) |
void |
setOverrideUserName(String userName) |
void |
setUseJvmChmod(boolean useJvmChmod)
to use or not the jvm method for file permissions: user all not active for group permissions
|
protected void |
validate() |
public String getDuplicateBehavior()
Archiver
getDuplicateBehavior
in interface Archiver
public void setDuplicateBehavior(String duplicate)
Archiver
ArchiverException
Archiver.DUPLICATES_ADD
, Archiver.DUPLICATES_SKIP
, Archiver.DUPLICATES_PRESERVE
,
Archiver.DUPLICATES_FAIL
.setDuplicateBehavior
in interface Archiver
public final void setFileMode(int mode)
setFileMode
in interface Archiver
public final void setDefaultFileMode(int mode)
setDefaultFileMode
in interface Archiver
public final int getOverrideFileMode()
getOverrideFileMode
in interface Archiver
public final int getFileMode()
getFileMode
in interface Archiver
public final int getDefaultFileMode()
getDefaultFileMode
in interface Archiver
@Deprecated public final int getRawDefaultFileMode()
Archiver.getDefaultFileMode()
.public final void setDirectoryMode(int mode)
Archiver
setDirectoryMode
in interface Archiver
public final void setDefaultDirectoryMode(int mode)
Archiver
setDefaultDirectoryMode
in interface Archiver
public final int getOverrideDirectoryMode()
getOverrideDirectoryMode
in interface Archiver
public final int getDirectoryMode()
Archiver
getDirectoryMode
in interface Archiver
public final int getDefaultDirectoryMode()
getDefaultDirectoryMode
in interface Archiver
public boolean getIncludeEmptyDirs()
getIncludeEmptyDirs
in interface Archiver
public void setIncludeEmptyDirs(boolean includeEmptyDirs)
setIncludeEmptyDirs
in interface Archiver
public void addDirectory(@Nonnull File directory) throws ArchiverException
Archiver
Archiver.addFileSet(FileSet)
.addDirectory
in interface Archiver
ArchiverException
public void addDirectory(@Nonnull File directory, String prefix) throws ArchiverException
Archiver
Archiver.addFileSet(FileSet)
.addDirectory
in interface Archiver
ArchiverException
public void addDirectory(@Nonnull File directory, String[] includes, String[] excludes) throws ArchiverException
Archiver
Archiver.addFileSet(FileSet)
.addDirectory
in interface Archiver
ArchiverException
public void addDirectory(@Nonnull File directory, String prefix, String[] includes, String[] excludes) throws ArchiverException
Archiver
Archiver.addFileSet(FileSet)
.addDirectory
in interface Archiver
ArchiverException
public void addFileSet(@Nonnull FileSet fileSet) throws ArchiverException
Archiver
Archiver.addDirectory(File)
,
Archiver.addDirectory(File, String)
, Archiver.addDirectory(File, String[], String[])
, and
Archiver.addDirectory(File, String, String[], String[])
. However, as these methods are in widespread use, they
cannot easily be deprecated.addFileSet
in interface Archiver
ArchiverException
- Adding the file set failed.public void addFile(@Nonnull File inputFile, @Nonnull String destFileName) throws ArchiverException
addFile
in interface Archiver
ArchiverException
public void addSymlink(String symlinkName, String symlinkDestination) throws ArchiverException
addSymlink
in interface Archiver
ArchiverException
public void addSymlink(String symlinkName, int permissions, String symlinkDestination) throws ArchiverException
addSymlink
in interface Archiver
ArchiverException
protected ArchiveEntry asArchiveEntry(@Nonnull org.codehaus.plexus.components.io.resources.PlexusIoResource resource, String destFileName, int permissions, org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection) throws ArchiverException
ArchiverException
public void addResource(org.codehaus.plexus.components.io.resources.PlexusIoResource resource, String destFileName, int permissions) throws ArchiverException
Archiver
addResource
in interface Archiver
ArchiverException
public void addFile(@Nonnull File inputFile, @Nonnull String destFileName, int permissions) throws ArchiverException
addFile
in interface Archiver
ArchiverException
@Nonnull public ResourceIterator getResources() throws ArchiverException
Archiver
ArchiveEntry
, which have previously been added by calls to
Archiver.addResources(PlexusIoResourceCollection)
, Archiver.addResource(PlexusIoResource, String, int)
,
Archiver.addFileSet(FileSet)
, etc.getResources
in interface Archiver
ArchiverException
public Map<String,ArchiveEntry> getFiles()
public File getDestFile()
getDestFile
in interface Archiver
public void setDestFile(File destFile)
setDestFile
in interface Archiver
protected org.codehaus.plexus.logging.Logger getLogger()
getLogger
in class org.codehaus.plexus.logging.AbstractLogEnabled
protected org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection asResourceCollection(ArchivedFileSet fileSet, Charset charset) throws ArchiverException
ArchiverException
public void addResources(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection) throws ArchiverException
addResources
in interface Archiver
ArchiverException
public void addArchivedFileSet(ArchivedFileSet fileSet) throws ArchiverException
Archiver
Archiver.addArchivedFileSet(File)
, Archiver.addArchivedFileSet(File, String[], String[])
, and
Archiver.addArchivedFileSet(File, String, String[], String[])
. However, as these methods are in widespread use,
they cannot easily be deprecated.
Stream transformers are supported on this methodaddArchivedFileSet
in interface Archiver
ArchiverException
public void addArchivedFileSet(ArchivedFileSet fileSet, Charset charset) throws ArchiverException
Archiver
Archiver.addArchivedFileSet(File)
, Archiver.addArchivedFileSet(File, String[], String[])
, and
Archiver.addArchivedFileSet(File, String, String[], String[])
. However, as these methods are in widespread use,
they cannot easily be deprecated.addArchivedFileSet
in interface Archiver
fileSet
- the fileSet to addcharset
- the encoding to use, particularly useful to specific non-standard filename encodings
for some kinds of archives (for instance zip files)
Stream transformers are supported on this methodArchiverException
public void addArchivedFileSet(@Nonnull File archiveFile, String prefix, String[] includes, String[] excludes) throws ArchiverException
Archiver
Archiver.addArchivedFileSet(ArchivedFileSet)
.addArchivedFileSet
in interface Archiver
ArchiverException
public void addArchivedFileSet(@Nonnull File archiveFile, String prefix) throws ArchiverException
Archiver
Archiver.addArchivedFileSet(ArchivedFileSet)
.addArchivedFileSet
in interface Archiver
ArchiverException
public void addArchivedFileSet(@Nonnull File archiveFile, String[] includes, String[] excludes) throws ArchiverException
Archiver
Archiver.addArchivedFileSet(ArchivedFileSet)
.addArchivedFileSet
in interface Archiver
ArchiverException
public void addArchivedFileSet(@Nonnull File archiveFile) throws ArchiverException
Archiver
Archiver.addArchivedFileSet(ArchivedFileSet)
.addArchivedFileSet
in interface Archiver
ArchiverException
public void contextualize(org.codehaus.plexus.context.Context context) throws org.codehaus.plexus.context.ContextException
contextualize
in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
org.codehaus.plexus.context.ContextException
public boolean isForced()
Archiver
Returns, whether recreating the archive is forced (default). Setting this option to false means, that the archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't recreated) on the cost that you get inaccurate results from time to time. In particular, removal of source files won't be detected.
An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be
ignored. The method Archiver.isSupportingForced()
may be called to check whether an archiver does support
uptodate checks.
isForced
in interface Archiver
Archiver.setForced(boolean)
,
Archiver.isSupportingForced()
public void setForced(boolean forced)
Archiver
Sets, whether recreating the archive is forced (default). Setting this option to false means, that the archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't recreated) on the cost that you get inaccurate results from time to time. In particular, removal of source files won't be detected.
An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be
ignored. The method Archiver.isSupportingForced()
may be called to check whether an archiver does support
uptodate checks.
setForced
in interface Archiver
forced
- true, if the target archive should always be created; false otherwiseArchiver.isForced()
,
Archiver.isSupportingForced()
public void addArchiveFinalizer(ArchiveFinalizer finalizer)
addArchiveFinalizer
in interface FinalizerEnabled
public void setArchiveFinalizers(List<ArchiveFinalizer> archiveFinalizers)
setArchiveFinalizers
in interface FinalizerEnabled
public void setDotFileDirectory(File dotFileDirectory)
setDotFileDirectory
in interface Archiver
protected boolean isUptodate() throws ArchiverException
ArchiverException
protected boolean checkForced() throws ArchiverException
ArchiverException
public boolean isSupportingForced()
Archiver
Archiver.setForced(boolean)
to true.isSupportingForced
in interface Archiver
Archiver.setForced(boolean)
,
Archiver.isForced()
protected void runArchiveFinalizers() throws ArchiverException
ArchiverException
public final void createArchive() throws ArchiverException, IOException
createArchive
in interface Archiver
ArchiverException
IOException
protected boolean hasVirtualFiles()
protected boolean revert(StringBuffer messageBuffer)
protected void validate() throws ArchiverException, IOException
ArchiverException
IOException
protected void postCreateArchive() throws ArchiverException, IOException
ArchiverException
IOException
protected abstract String getArchiveType()
protected abstract void close() throws IOException
IOException
protected void cleanUp() throws IOException
IOException
protected abstract void execute() throws ArchiverException, IOException
ArchiverException
IOException
public boolean isUseJvmChmod()
isUseJvmChmod
in interface Archiver
public void setUseJvmChmod(boolean useJvmChmod)
Archiver
setUseJvmChmod
in interface Archiver
public boolean isIgnorePermissions()
isIgnorePermissions
in interface Archiver
public void setIgnorePermissions(boolean ignorePermissions)
setIgnorePermissions
in interface Archiver
@Deprecated public void setLastModifiedDate(Date lastModifiedDate)
setLastModifiedTime(FileTime)
instead.Archiver
setLastModifiedDate
in interface Archiver
@Deprecated public Date getLastModifiedDate()
getLastModifiedTime()
instead.getLastModifiedDate
in interface Archiver
public void setLastModifiedTime(FileTime lastModifiedTime)
Archiver
setLastModifiedTime
in interface Archiver
lastModifiedTime
- to set in the archive entriesArchiver.getLastModifiedTime()
public FileTime getLastModifiedTime()
Archiver
getLastModifiedTime
in interface Archiver
Archiver.setLastModifiedTime(FileTime)
public void setFilenameComparator(Comparator<String> filenameComparator)
Archiver
setFilenameComparator
in interface Archiver
public Comparator<String> getFilenameComparator()
public void setOverrideUid(int uid)
setOverrideUid
in interface Archiver
public void setOverrideUserName(String userName)
setOverrideUserName
in interface Archiver
public int getOverrideUid()
getOverrideUid
in interface Archiver
public String getOverrideUserName()
getOverrideUserName
in interface Archiver
public void setOverrideGid(int gid)
setOverrideGid
in interface Archiver
public void setOverrideGroupName(String groupName)
setOverrideGroupName
in interface Archiver
public int getOverrideGid()
getOverrideGid
in interface Archiver
public String getOverrideGroupName()
getOverrideGroupName
in interface Archiver
@Deprecated public void configureReproducible(Date lastModifiedDate)
configureReproducibleBuild(FileTime)
instead.Archiver
Archiver.configureReproducibleBuild(FileTime)
with the Date transformed into FileTime.configureReproducible
in interface Archiver
lastModifiedDate
- the date to use for archive entries last modified timepublic void configureReproducibleBuild(FileTime lastModifiedTime)
Archiver
This will configure:
configureReproducibleBuild
in interface Archiver
lastModifiedTime
- The last modification time of the entriesprotected FileTime normalizeLastModifiedTime(FileTime lastModifiedTime)
tar uses UTC timestamp, but zip uses local time then requires tweaks to make the value reproducible whatever the current timezone is.
lastModifiedTime
- The last modification timeconfigureReproducibleBuild(FileTime)
Copyright © 2001–2022 Codehaus Plexus. All rights reserved.