Package org.codehaus.plexus.archiver.jar
Class JarToolModularJarArchiver
java.lang.Object
org.codehaus.plexus.archiver.AbstractArchiver
org.codehaus.plexus.archiver.zip.AbstractZipArchiver
org.codehaus.plexus.archiver.zip.ZipArchiver
org.codehaus.plexus.archiver.jar.JarArchiver
org.codehaus.plexus.archiver.jar.ModularJarArchiver
org.codehaus.plexus.archiver.jar.JarToolModularJarArchiver
- All Implemented Interfaces:
Archiver
,FinalizerEnabled
A
ModularJarArchiver
implementation that uses
the jar
tool provided by
java.util.spi.ToolProvider
to create
modular JAR files.
The basic JAR archive is created by JarArchiver
and the jar
tool is used to upgrade it to modular JAR.
If the JAR file does not contain module descriptor
or the JDK does not provide the jar
tool
(for example JDK prior to Java 9), then the
archive created by JarArchiver
is left unchanged.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codehaus.plexus.archiver.jar.JarArchiver
JarArchiver.FilesetManifestConfig
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private Object
private static final String
private boolean
private static final Pattern
Fields inherited from class org.codehaus.plexus.archiver.zip.AbstractZipArchiver
addedDirs, addingNewFiles, archiveType, doubleFilePass, duplicate, entries, skipWriting, zipArchiveOutputStream
Fields inherited from interface org.codehaus.plexus.archiver.Archiver
DEFAULT_DIR_MODE, DEFAULT_FILE_MODE, DEFAULT_SYMLILNK_MODE, DUPLICATES_ADD, DUPLICATES_FAIL, DUPLICATES_PRESERVE, DUPLICATES_SKIP, DUPLICATES_VALID_BEHAVIORS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Fallback to rewrite the JAR file with the correct timestamp if the--date
option is not available.private String[]
Prepares the arguments for the jar tool.private boolean
isJarDateOptionSupported
(Method runMethod) Check support for--date
option introduced since Java 17.0.3 (JDK-8279925).private boolean
isModuleDescriptor
(String path) Returnstrue
ifpath
is a module descriptor.protected void
This method is called after the archive creation completes successfully (no exceptions are thrown).private static FileTime
revertToLocalTime
(FileTime time) protected void
zipFile
(org.apache.commons.compress.parallel.InputStreamSupplier is, ConcurrentJarCreator zOut, String vPath, long lastModified, File fromArchive, int mode, String symlinkDestination, boolean addInParallel) Overridden from Zip class to deal with manifests and index lists.Methods inherited from class org.codehaus.plexus.archiver.jar.ModularJarArchiver
createManifest, getManifestMainClass, getModuleMainClass, getModuleVersion, reset, setModuleMainClass, setModuleVersion
Methods inherited from class org.codehaus.plexus.archiver.jar.JarArchiver
addConfiguredIndexJars, addConfiguredManifest, cleanUp, createEmptyZip, finalizeZipOutputStream, findJarName, hasVirtualFiles, initZipOutputStream, setFilesetmanifest, setIndex, setManifest, setManifestEncoding, setMinimalDefaultManifest, setZipEntryTime, writeIndexLikeList
Methods inherited from class org.codehaus.plexus.archiver.zip.AbstractZipArchiver
addResources, close, execute, getArchiveType, getComment, getEncoding, isCompress, isFilesonly, isInUpdateMode, isRecompressAddedZips, isSupportingForced, normalizeLastModifiedTime, revert, setComment, setCompress, setEncoding, setFilesonly, setRecompressAddedZips, setUpdateMode, zipDir, zipFile
Methods inherited from class org.codehaus.plexus.archiver.AbstractArchiver
addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchiveFinalizer, addDirectory, addDirectory, addDirectory, addDirectory, addFile, addFile, addFileSet, addResource, addResources, addSymlink, addSymlink, asArchiveEntry, asResourceCollection, checkForced, configureReproducible, configureReproducibleBuild, createArchive, getDefaultDirectoryMode, getDefaultFileMode, getDestFile, getDirectoryMode, getDuplicateBehavior, getFileMode, getFilenameComparator, getFiles, getIncludeEmptyDirs, getLastModifiedDate, getLastModifiedTime, getLogger, getOverrideDirectoryMode, getOverrideFileMode, getOverrideGid, getOverrideGroupName, getOverrideUid, getOverrideUserName, getRawDefaultFileMode, getResources, getUmask, isForced, isIgnorePermissions, isUptodate, isUseJvmChmod, runArchiveFinalizers, setArchiveFinalizers, setDefaultDirectoryMode, setDefaultFileMode, setDestFile, setDirectoryMode, setDotFileDirectory, setDuplicateBehavior, setFileMode, setFilenameComparator, setForced, setIgnorePermissions, setIncludeEmptyDirs, setLastModifiedDate, setLastModifiedTime, setOverrideGid, setOverrideGroupName, setOverrideUid, setOverrideUserName, setUmask, setUseJvmChmod, validate
-
Field Details
-
MODULE_DESCRIPTOR_FILE_NAME
- See Also:
-
MRJAR_VERSION_AREA
-
jarTool
-
moduleDescriptorFound
private boolean moduleDescriptorFound -
hasJarDateOption
private boolean hasJarDateOption
-
-
Constructor Details
-
JarToolModularJarArchiver
public JarToolModularJarArchiver()
-
-
Method Details
-
zipFile
protected void zipFile(org.apache.commons.compress.parallel.InputStreamSupplier is, ConcurrentJarCreator zOut, String vPath, long lastModified, File fromArchive, int mode, String symlinkDestination, boolean addInParallel) throws IOException, ArchiverException Description copied from class:JarArchiver
Overridden from Zip class to deal with manifests and index lists.- Overrides:
zipFile
in classJarArchiver
- Parameters:
is
- 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 tofalse
it is added synchronously. If the entry is symbolic link this parameter is ignored.- Throws:
IOException
ArchiverException
-
postCreateArchive
Description copied from class:AbstractArchiver
This method is called after the archive creation completes successfully (no exceptions are thrown). Subclasses may override this method in order to augment or validate the archive after it is created.- Overrides:
postCreateArchive
in classAbstractArchiver
- Throws:
ArchiverException
-
fixLastModifiedTimeZipEntries
Fallback to rewrite the JAR file with the correct timestamp if the--date
option is not available.- Throws:
IOException
-
isModuleDescriptor
Returnstrue
ifpath
is a module descriptor. -
getJarToolArguments
Prepares the arguments for the jar tool. It takes into account the module version, main class, etc.- Throws:
IOException
-
revertToLocalTime
-
isJarDateOptionSupported
Check support for--date
option introduced since Java 17.0.3 (JDK-8279925).- Returns:
- true if the JAR tool supports the
--date
option
-