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
@Named("mjar") public class JarToolModularJarArchiver extends ModularJarArchiverAModularJarArchiverimplementation that uses thejartool provided byjava.util.spi.ToolProviderto create modular JAR files.The basic JAR archive is created by
JarArchiverand thejartool is used to upgrade it to modular JAR.If the JAR file does not contain module descriptor or the JDK does not provide the
jartool (for example JDK prior to Java 9), then the archive created byJarArchiveris left unchanged.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.plexus.archiver.jar.JarArchiver
JarArchiver.FilesetManifestConfig
-
-
Field Summary
Fields Modifier and Type Field Description private booleanhasJarDateOptionprivate java.lang.ObjectjarToolprivate static java.lang.StringMODULE_DESCRIPTOR_FILE_NAMEprivate booleanmoduleDescriptorFoundprivate static java.util.regex.PatternMRJAR_VERSION_AREA-
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 Constructor Description JarToolModularJarArchiver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidfixLastModifiedTimeZipEntries()Fallback to rewrite the JAR file with the correct timestamp if the--dateoption is not available.private java.lang.String[]getJarToolArguments()Prepares the arguments for the jar tool.private booleanisJarDateOptionSupported(java.lang.reflect.Method runMethod)Check support for--dateoption introduced since Java 17.0.3 (JDK-8279925).private booleanisModuleDescriptor(java.lang.String path)Returnstrueifpathis a module descriptor.protected voidpostCreateArchive()This method is called after the archive creation completes successfully (no exceptions are thrown).private static java.nio.file.attribute.FileTimerevertToLocalTime(java.nio.file.attribute.FileTime time)protected voidzipFile(org.apache.commons.compress.parallel.InputStreamSupplier is, ConcurrentJarCreator zOut, java.lang.String vPath, long lastModified, java.io.File fromArchive, int mode, java.lang.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, getFiles, 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, 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 Detail
-
MODULE_DESCRIPTOR_FILE_NAME
private static final java.lang.String MODULE_DESCRIPTOR_FILE_NAME
- See Also:
- Constant Field Values
-
MRJAR_VERSION_AREA
private static final java.util.regex.Pattern MRJAR_VERSION_AREA
-
jarTool
private java.lang.Object jarTool
-
moduleDescriptorFound
private boolean moduleDescriptorFound
-
hasJarDateOption
private boolean hasJarDateOption
-
-
Method Detail
-
zipFile
protected void zipFile(org.apache.commons.compress.parallel.InputStreamSupplier is, ConcurrentJarCreator zOut, java.lang.String vPath, long lastModified, java.io.File fromArchive, int mode, java.lang.String symlinkDestination, boolean addInParallel) throws java.io.IOException, ArchiverExceptionDescription copied from class:JarArchiverOverridden from Zip class to deal with manifests and index lists.- Overrides:
zipFilein 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 thisaddInParallel- Indicates if the entry should be add in parallel. If set tofalseit is added synchronously. If the entry is symbolic link this parameter is ignored.- Throws:
java.io.IOExceptionArchiverException
-
postCreateArchive
protected void postCreateArchive() throws ArchiverExceptionDescription copied from class:AbstractArchiverThis 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:
postCreateArchivein classAbstractArchiver- Throws:
ArchiverException
-
fixLastModifiedTimeZipEntries
private void fixLastModifiedTimeZipEntries() throws java.io.IOExceptionFallback to rewrite the JAR file with the correct timestamp if the--dateoption is not available.- Throws:
java.io.IOException
-
isModuleDescriptor
private boolean isModuleDescriptor(java.lang.String path)
Returnstrueifpathis a module descriptor.
-
getJarToolArguments
private java.lang.String[] getJarToolArguments() throws java.io.IOExceptionPrepares the arguments for the jar tool. It takes into account the module version, main class, etc.- Throws:
java.io.IOException
-
revertToLocalTime
private static java.nio.file.attribute.FileTime revertToLocalTime(java.nio.file.attribute.FileTime time)
-
isJarDateOptionSupported
private boolean isJarDateOptionSupported(java.lang.reflect.Method runMethod)
Check support for--dateoption introduced since Java 17.0.3 (JDK-8279925).- Returns:
- true if the JAR tool supports the
--dateoption
-
-