public class JarArchiver extends ZipArchiver
| Modifier and Type | Class and Description |
|---|---|
static class |
JarArchiver.FilesetManifestConfig |
| Modifier and Type | Field and Description |
|---|---|
private Manifest |
configuredManifest
merged manifests added through addConfiguredManifest
|
private boolean |
createEmpty
whether to really create the archive in createEmptyZip, will
get set in getResourcesToAdd.
|
private Manifest |
filesetManifest
merged manifests added through filesets
|
private JarArchiver.FilesetManifestConfig |
filesetManifestConfig
whether to merge fileset manifests;
value is true if filesetmanifest is 'merge' or 'mergewithoutmain'
|
private boolean |
index
jar index is JDK 1.3+ only
|
private static java.lang.String |
INDEX_NAME
The index file name.
|
private java.util.ArrayList<java.lang.String> |
indexJars
Path containing jars that shall be indexed in addition to this archive.
|
private Manifest |
manifest
the manifest specified by the 'manifest' attribute *
|
private static java.lang.String |
MANIFEST_NAME
The manifest file name.
|
private java.io.File |
manifestFile
The file found from the 'manifest' attribute.
|
private boolean |
mergeManifestsMain
whether to merge the main section of fileset manifests;
value is true if filesetmanifest is 'merge'
|
private static java.lang.String |
META_INF_NAME
the name of the meta-inf dir
|
private Manifest |
originalManifest
Manifest of original archive, will be set to null if not in
update mode.
|
private java.util.Vector<java.lang.String> |
rootEntries
Stores all files that are in the root of the archive (i.e.
|
private Manifest |
savedConfiguredManifest
shadow of the above if upToDate check alters the value
|
addedDirs, addingNewFiles, archiveType, doubleFilePass, duplicate, entries, skipWriting, zipArchiveOutputStreamDEFAULT_DIR_MODE, DEFAULT_FILE_MODE, DEFAULT_SYMLILNK_MODE, DUPLICATES_ADD, DUPLICATES_FAIL, DUPLICATES_PRESERVE, DUPLICATES_SKIP, DUPLICATES_VALID_BEHAVIORS, ROLE| Constructor and Description |
|---|
JarArchiver()
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConfiguredIndexJars(java.io.File indexJar) |
void |
addConfiguredManifest(Manifest newManifest)
Allows the manifest for the archive file to be provided inline
in the build file rather than in an external file.
|
protected void |
cleanUp()
Make sure we don't think we already have a MANIFEST next time this task
gets executed.
|
protected boolean |
createEmptyZip(java.io.File zipFile)
Create an empty zip file
|
private void |
createIndexList(ConcurrentJarCreator zOut)
Create the index list to speed up classloading.
|
private Manifest |
createManifest() |
private void |
filesetManifest(java.io.File file,
java.io.InputStream is) |
protected void |
finalizeZipOutputStream(ConcurrentJarCreator zOut) |
protected static java.lang.String |
findJarName(java.lang.String fileName,
java.lang.String[] classpath)
try to guess the name of the given file.
|
private Manifest |
getManifest(java.io.File manifestFile) |
private Manifest |
getManifest(java.io.InputStream is) |
protected static void |
grabFilesAndDirs(java.lang.String file,
java.util.List<java.lang.String> dirs,
java.util.List<java.lang.String> files)
Grab lists of all root-level files and all directories
contained in the given archive.
|
protected boolean |
hasVirtualFiles() |
protected void |
initZipOutputStream(ConcurrentJarCreator zOut)
method for subclasses to override
|
void |
reset()
reset to default values.
|
void |
setFilesetmanifest(JarArchiver.FilesetManifestConfig config)
Behavior when a Manifest is found in a zipfileset or zipgroupfileset file.
|
void |
setIndex(boolean flag)
Set whether or not to create an index list for classes.
|
void |
setManifest(java.io.File manifestFile)
The manifest file to use.
|
void |
setManifestEncoding(java.lang.String manifestEncoding)
Deprecated.
|
protected void |
writeIndexLikeList(java.util.List<java.lang.String> dirs,
java.util.List<java.lang.String> files,
java.io.PrintWriter writer)
Writes the directory entries from the first and the filenames
from the second list to the given writer, one entry per line.
|
private void |
writeManifest(ConcurrentJarCreator zOut,
Manifest manifest) |
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)
Overridden from Zip class to deal with manifests and index lists.
|
addResources, close, createInputStreamSupplier, execute, getArchiveType, getComment, getEncoding, isCompress, isFilesonly, isInUpdateMode, isRecompressAddedZips, isSupportingForced, revert, setComment, setCompress, setEncoding, setFilesonly, setRecompressAddedZips, setUpdateMode, zipDir, zipFileaddArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchiveFinalizer, addDirectory, addDirectory, addDirectory, addDirectory, addFile, addFile, addFileSet, addResource, addResources, addSymlink, addSymlink, asArchiveEntry, asResourceCollection, checkForced, contextualize, createArchive, getDefaultDirectoryMode, getDefaultFileMode, getDestFile, getDirectoryMode, getDuplicateBehavior, getFileMode, getFiles, getIncludeEmptyDirs, getLogger, getOverrideDirectoryMode, getOverrideFileMode, getRawDefaultFileMode, getResources, isForced, isIgnorePermissions, isUptodate, isUseJvmChmod, postCreateArchive, runArchiveFinalizers, setArchiveFinalizers, setDefaultDirectoryMode, setDefaultFileMode, setDestFile, setDirectoryMode, setDotFileDirectory, setDuplicateBehavior, setFileMode, setForced, setIgnorePermissions, setIncludeEmptyDirs, setUseJvmChmod, validateprivate static final java.lang.String META_INF_NAME
private static final java.lang.String INDEX_NAME
private static final java.lang.String MANIFEST_NAME
private Manifest configuredManifest
private Manifest savedConfiguredManifest
private Manifest filesetManifest
private Manifest originalManifest
private JarArchiver.FilesetManifestConfig filesetManifestConfig
private boolean mergeManifestsMain
private Manifest manifest
private java.io.File manifestFile
private boolean index
private boolean createEmpty
private java.util.Vector<java.lang.String> rootEntries
private java.util.ArrayList<java.lang.String> indexJars
public void setIndex(boolean flag)
flag - true to create an index@Deprecated public void setManifestEncoding(java.lang.String manifestEncoding)
public void addConfiguredManifest(Manifest newManifest) throws ManifestException
newManifest - The new manifestManifestException - .public void setManifest(java.io.File manifestFile)
throws ArchiverException
manifestFile - the manifest file to use.ArchiverException - .private Manifest getManifest(java.io.File manifestFile) throws ArchiverException
ArchiverExceptionprivate Manifest getManifest(java.io.InputStream is) throws ArchiverException
ArchiverExceptionpublic void setFilesetmanifest(JarArchiver.FilesetManifestConfig config)
config - setting for found manifest behavior.public void addConfiguredIndexJars(java.io.File indexJar)
indexJar - The indexjarprotected void initZipOutputStream(ConcurrentJarCreator zOut) throws ArchiverException, java.io.IOException
AbstractZipArchiverinitZipOutputStream in class AbstractZipArchiverzOut - The output streamArchiverExceptionjava.io.IOExceptionprotected boolean hasVirtualFiles()
hasVirtualFiles in class AbstractArchiverprivate Manifest createManifest() throws ArchiverException
ArchiverExceptionprivate void writeManifest(ConcurrentJarCreator zOut, Manifest manifest) throws java.io.IOException, ArchiverException
java.io.IOExceptionArchiverExceptionprotected void finalizeZipOutputStream(ConcurrentJarCreator zOut) throws java.io.IOException, ArchiverException
finalizeZipOutputStream in class AbstractZipArchiverjava.io.IOExceptionArchiverExceptionprivate void createIndexList(ConcurrentJarCreator zOut) throws java.io.IOException, ArchiverException
zOut - the zip stream representing the jar being built.java.io.IOException - thrown if there is an error while creating the
index and adding it to the zip stream.ArchiverException - .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,
ArchiverException
zipFile in class AbstractZipArchiveris - 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 to false it is added synchronously.
If the entry is symbolic link this parameter is ignored.java.io.IOExceptionArchiverExceptionprivate void filesetManifest(java.io.File file,
java.io.InputStream is)
throws ArchiverException
ArchiverExceptionprotected boolean createEmptyZip(java.io.File zipFile)
throws ArchiverException
AbstractZipArchivercreateEmptyZip in class AbstractZipArchiverzipFile - The fileArchiverExceptionprotected void cleanUp()
throws java.io.IOException
cleanUp in class AbstractZipArchiverjava.io.IOExceptionAbstractZipArchiver.cleanUp()public void reset()
reset in class AbstractZipArchiverAbstractZipArchiver.reset()protected final void writeIndexLikeList(java.util.List<java.lang.String> dirs,
java.util.List<java.lang.String> files,
java.io.PrintWriter writer)
dirs - The directoriesfiles - The fileswriter - The printwriter ;)protected static java.lang.String findJarName(java.lang.String fileName,
java.lang.String[] classpath)
If this jar has a classpath attribute in its manifest, we can assume that it will only require an index of jars listed there. try to find which classpath entry is most likely the one the given file name points to.
In the absence of a classpath attribute, assume the other files will be placed inside the same directory as this jar and use their basename.
if there is a classpath and the given file doesn't match any of its entries, return null.
fileName - .classpath - .protected static void grabFilesAndDirs(java.lang.String file,
java.util.List<java.lang.String> dirs,
java.util.List<java.lang.String> files)
throws java.io.IOException
file - .files - .dirs - .java.io.IOException - .