Interface Archiver
- All Known Implementing Classes:
AbstractArchiver,AbstractZipArchiver,BZip2Archiver,DelgatingArchiver,DirectoryArchiver,DryRunArchiver,EarArchiver,GZipArchiver,JarArchiver,JarToolModularJarArchiver,ModularJarArchiver,NoOpArchiver,RarArchiver,SnappyArchiver,TarArchiver,TarBZip2Archiver,TarGZipArchiver,TarSnappyArchiver,TarXZArchiver,TarZstdArchiver,TBZ2Archiver,TGZArchiver,TrackingArchiver,TXZArchiver,TZstdArchiver,WarArchiver,XZArchiver,ZipArchiver,ZstdArchiver
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArchivedFileSet(File archiveFile) Deprecated.Will go away in next major versionvoidaddArchivedFileSet(File archiveFile, String prefix) Deprecated.Will go away in next major versionvoidaddArchivedFileSet(File archiveFile, String[] includes, String[] excludes) Deprecated.Will go away in next major versionvoidaddArchivedFileSet(File archiveFile, String prefix, String[] includes, String[] excludes) Deprecated.Will go away in next major versionvoidaddArchivedFileSet(ArchivedFileSet fileSet) Adds the given archive file set to the archive.voidaddArchivedFileSet(ArchivedFileSet fileSet, Charset charset) Adds the given archive file set to the archive.voidaddDirectory(File directory) Deprecated.Will go away in next major versionvoidaddDirectory(File directory, String prefix) Deprecated.Will go away in next major versionvoidaddDirectory(File directory, String[] includes, String[] excludes) Deprecated.Will go away in next major versionvoidaddDirectory(File directory, String prefix, String[] includes, String[] excludes) Deprecated.Will go away in next major versionvoidvoidvoidaddFileSet(FileSet fileSet) Adds the given file set to the archive.voidaddResource(org.codehaus.plexus.components.io.resources.PlexusIoResource resource, String destFileName, int permissions) Adds the given resource collection to the archive.voidaddResources(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection resources) Adds the given resource collection to the archive.voidaddSymlink(String symlinkName, int permissions, String symlinkDestination) voidaddSymlink(String symlinkName, String symlinkDestination) voidconfigureReproducible(Date lastModifiedDate) Deprecated.UseconfigureReproducibleBuild(FileTime)instead.voidconfigureReproducibleBuild(FileTime lastModifiedTime) Configure the archiver to create archives in a reproducible way (see Reproducible Builds).voidintintintGets the forced mode for directories, falling back to default if none is forced.Returns the behavior of this archiver when duplicate files are detected.intgetFiles()Deprecated.UsegetResources()booleanDeprecated.UsegetLastModifiedTime()insteadReturns the last modification time of the archiver.intintintintReturns an iterator over instances ofArchiveEntry, which have previously been added by calls toaddResources(PlexusIoResourceCollection),addResource(PlexusIoResource, String, int),addFileSet(FileSet), etc.intgetUmask()booleanisForced()Returns, whether recreating the archive is forced (default).booleanbooleanReturns, whether the archive supports uptodate checks.booleanDeprecated.this setting is now ignored.voidsetDefaultDirectoryMode(int mode) This is the "default" value we should use if no other value is specifiedvoidsetDefaultFileMode(int mode) voidsetDestFile(File destFile) voidsetDirectoryMode(int mode) This is the forced mode that should be used regardless if set, otherwise falls back to default.voidsetDotFileDirectory(File dotFileDirectory) voidsetDuplicateBehavior(String duplicate) Set the behavior of this archiver when duplicate files are detected.voidsetFileMode(int mode) voidsetFilenameComparator(Comparator<String> filenameComparator) Set filename comparator, used to sort file entries when scanning directories since File.list() does not guarantee any order.voidsetForced(boolean forced) Sets, whether recreating the archive is forced (default).voidsetIgnorePermissions(boolean ignorePermissions) voidsetIncludeEmptyDirs(boolean includeEmptyDirs) voidsetLastModifiedDate(Date lastModifiedDate) Deprecated.UsesetLastModifiedTime(FileTime)insteadvoidsetLastModifiedTime(FileTime lastModifiedTime) Sets the last modification time of the entries (if non null).voidsetOverrideGid(int gid) voidsetOverrideGroupName(String groupName) voidsetOverrideUid(int uid) voidsetOverrideUserName(String userName) voidsetUmask(int umask) voidsetUseJvmChmod(boolean useJvmChmod) Deprecated.this setting is now ignored.
-
Field Details
-
DEFAULT_DIR_MODE
static final int DEFAULT_DIR_MODEDefault value for the dirmode attribute.- See Also:
-
DEFAULT_FILE_MODE
static final int DEFAULT_FILE_MODEDefault value for the filemode attribute.- See Also:
-
DEFAULT_SYMLILNK_MODE
static final int DEFAULT_SYMLILNK_MODEDefault value for the symlinkmode attribute.- See Also:
-
DUPLICATES_ADD
- See Also:
-
DUPLICATES_PRESERVE
- See Also:
-
DUPLICATES_SKIP
- See Also:
-
DUPLICATES_FAIL
- See Also:
-
DUPLICATES_VALID_BEHAVIORS
-
-
Method Details
-
createArchive
- Throws:
ArchiverExceptionIOException
-
addDirectory
Deprecated.Will go away in next major versionObsolete, useaddFileSet(FileSet).- Throws:
ArchiverException
-
addDirectory
Deprecated.Will go away in next major versionObsolete, useaddFileSet(FileSet).- Throws:
ArchiverException
-
addDirectory
@Deprecated void addDirectory(@Nonnull File directory, String[] includes, String[] excludes) throws ArchiverException Deprecated.Will go away in next major versionObsolete, useaddFileSet(FileSet).- Throws:
ArchiverException
-
addDirectory
@Deprecated void addDirectory(@Nonnull File directory, String prefix, String[] includes, String[] excludes) throws ArchiverException Deprecated.Will go away in next major versionObsolete, useaddFileSet(FileSet).- Throws:
ArchiverException
-
addFileSet
Adds the given file set to the archive. This method is basically obsoletingaddDirectory(File),addDirectory(File, String),addDirectory(File, String[], String[]), andaddDirectory(File, String, String[], String[]). However, as these methods are in widespread use, they cannot easily be deprecated.- Throws:
ArchiverException- Adding the file set failed.- Since:
- 1.0-alpha-9
-
addSymlink
- Throws:
ArchiverException
-
addSymlink
void addSymlink(String symlinkName, int permissions, String symlinkDestination) throws ArchiverException - Throws:
ArchiverException
-
addFile
- Throws:
ArchiverException
-
addFile
void addFile(@Nonnull File inputFile, @Nonnull String destFileName, int permissions) throws ArchiverException - Throws:
ArchiverException
-
addArchivedFileSet
Deprecated.Will go away in next major versionObsolete, useaddArchivedFileSet(ArchivedFileSet).- Throws:
ArchiverException
-
addArchivedFileSet
@Deprecated void addArchivedFileSet(@Nonnull File archiveFile, String prefix) throws ArchiverException Deprecated.Will go away in next major versionObsolete, useaddArchivedFileSet(ArchivedFileSet).- Throws:
ArchiverException
-
addArchivedFileSet
@Deprecated void addArchivedFileSet(File archiveFile, String[] includes, String[] excludes) throws ArchiverException Deprecated.Will go away in next major versionObsolete, useaddArchivedFileSet(ArchivedFileSet).- Throws:
ArchiverException
-
addArchivedFileSet
@Deprecated void addArchivedFileSet(@Nonnull File archiveFile, String prefix, String[] includes, String[] excludes) throws ArchiverException Deprecated.Will go away in next major versionObsolete, useaddArchivedFileSet(ArchivedFileSet).- Throws:
ArchiverException
-
addArchivedFileSet
Adds the given archive file set to the archive. This method is basically obsoletingaddArchivedFileSet(File),addArchivedFileSet(File, String[], String[]), andaddArchivedFileSet(File, String, String[], String[]). However, as these methods are in widespread use, they cannot easily be deprecated. Stream transformers are supported on this method- Throws:
ArchiverException- Since:
- 1.0-alpha-9
-
addArchivedFileSet
Adds the given archive file set to the archive. This method is basically obsoletingaddArchivedFileSet(File),addArchivedFileSet(File, String[], String[]), andaddArchivedFileSet(File, String, String[], String[]). However, as these methods are in widespread use, they cannot easily be deprecated.- Parameters:
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 methodcharset-- Throws:
ArchiverException- Since:
- 1.0-alpha-9
-
addResource
void addResource(org.codehaus.plexus.components.io.resources.PlexusIoResource resource, String destFileName, int permissions) throws ArchiverException Adds the given resource collection to the archive. Stream transformers are *not* supported on this method- Throws:
ArchiverException- Since:
- 1.0-alpha-10
-
addResources
void addResources(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection resources) throws ArchiverException Adds the given resource collection to the archive. Stream transformers are supported on this method- Throws:
ArchiverException- Since:
- 1.0-alpha-10
-
getDestFile
File getDestFile() -
setDestFile
-
setFileMode
void setFileMode(int mode) -
getFileMode
int getFileMode() -
getOverrideFileMode
int getOverrideFileMode() -
setDefaultFileMode
void setDefaultFileMode(int mode) -
getDefaultFileMode
int getDefaultFileMode() -
setDirectoryMode
void setDirectoryMode(int mode) This is the forced mode that should be used regardless if set, otherwise falls back to default.- Parameters:
mode-
-
getDirectoryMode
int getDirectoryMode()Gets the forced mode for directories, falling back to default if none is forced.- Returns:
-
getOverrideDirectoryMode
int getOverrideDirectoryMode() -
setDefaultDirectoryMode
void setDefaultDirectoryMode(int mode) This is the "default" value we should use if no other value is specified- Parameters:
mode-
-
getDefaultDirectoryMode
int getDefaultDirectoryMode() -
getIncludeEmptyDirs
boolean getIncludeEmptyDirs() -
setIncludeEmptyDirs
void setIncludeEmptyDirs(boolean includeEmptyDirs) -
setDotFileDirectory
-
getResources
Returns an iterator over instances ofArchiveEntry, which have previously been added by calls toaddResources(PlexusIoResourceCollection),addResource(PlexusIoResource, String, int),addFileSet(FileSet), etc.- Throws:
ArchiverException- Since:
- 1.0-alpha-10
-
getFiles
Deprecated.UsegetResources()Returns a map of the files that have been added to the archive.Note: The entry names in the map may use platform-specific path separators in the base implementation. However, archive format-specific implementations (such as ZIP-based archivers) should normalize paths according to their format requirements. For example, ZIP archivers normalize to forward slashes as required by the ZIP file specification.
- Returns:
- A map where keys are entry names and values are the corresponding ArchiveEntry objects.
-
isForced
boolean isForced()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
isSupportingForced()may be called to check whether an archiver does support uptodate checks.- Returns:
- true if the target archive should always be created; false otherwise
- See Also:
-
setForced
void setForced(boolean forced) 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
isSupportingForced()may be called to check whether an archiver does support uptodate checks.- Parameters:
forced- true, if the target archive should always be created; false otherwise- See Also:
-
isSupportingForced
boolean isSupportingForced()Returns, whether the archive supports uptodate checks. If so, you may setsetForced(boolean)to true.- Returns:
- true, if the archiver does support uptodate checks, false otherwise
- See Also:
-
getDuplicateBehavior
String getDuplicateBehavior()Returns the behavior of this archiver when duplicate files are detected. -
setDuplicateBehavior
Set the behavior of this archiver when duplicate files are detected. One of:
- add - Add the duplicates to the archive as duplicate entries
- skip/preserve - Leave the first entry encountered in the archive, skip the new one
- fail - throw an
ArchiverException
SeeDUPLICATES_ADD,DUPLICATES_SKIP,DUPLICATES_PRESERVE,DUPLICATES_FAIL. -
setUseJvmChmod
Deprecated.this setting is now ignored. The jvm is always used.to use or not the jvm method for file permissions: user all not active for group permissions- Parameters:
useJvmChmod-- Since:
- 1.1
-
isUseJvmChmod
Deprecated.this setting is now ignored. The jvm is always used.- Returns:
- Since:
- 1.1
-
isIgnorePermissions
boolean isIgnorePermissions()- Since:
- 1.1
-
setIgnorePermissions
void setIgnorePermissions(boolean ignorePermissions) - Since:
- 1.1
-
setLastModifiedDate
Deprecated.UsesetLastModifiedTime(FileTime)insteadDefine forced last modification date for entries (if non null).- Parameters:
lastModifiedDate-- Since:
- 4.2.0
-
getLastModifiedDate
Deprecated.UsegetLastModifiedTime()instead- Since:
- 4.2.0
-
setLastModifiedTime
Sets the last modification time of the entries (if non null).- Parameters:
lastModifiedTime- to set in the archive entries- Since:
- 4.3.0
- See Also:
-
getLastModifiedTime
FileTime getLastModifiedTime()Returns the last modification time of the archiver.- Returns:
- The last modification time of the archiver, null if not specified
- Since:
- 4.3.0
- See Also:
-
setFilenameComparator
Set filename comparator, used to sort file entries when scanning directories since File.list() does not guarantee any order.- Since:
- 4.2.0
-
setOverrideUid
void setOverrideUid(int uid) - Since:
- 4.2.0
-
setOverrideUserName
- Since:
- 4.2.0
-
getOverrideUid
int getOverrideUid()- Since:
- 4.2.0
-
getOverrideUserName
String getOverrideUserName()- Since:
- 4.2.0
-
setOverrideGid
void setOverrideGid(int gid) - Since:
- 4.2.0
-
setOverrideGroupName
- Since:
- 4.2.0
-
getOverrideGid
int getOverrideGid()- Since:
- 4.2.0
-
getOverrideGroupName
String getOverrideGroupName()- Since:
- 4.2.0
-
setUmask
void setUmask(int umask) - Since:
- 4.7.0
-
getUmask
int getUmask()- Since:
- 4.7.0
-
configureReproducible
Deprecated.UseconfigureReproducibleBuild(FileTime)instead.This method is obsolete and will just callconfigureReproducibleBuild(FileTime)with the Date transformed into FileTime.- Parameters:
lastModifiedDate- the date to use for archive entries last modified time- Since:
- 4.2.0
-
configureReproducibleBuild
Configure the archiver to create archives in a reproducible way (see Reproducible Builds).This will configure:
- reproducible archive entries order,
- defined entries timestamp
- Parameters:
lastModifiedTime- The last modification time of the entries- Since:
- 4.3.0
- See Also:
-