public class JarArchiver extends ZipArchiver
Modifier and Type | Class and Description |
---|---|
static class |
JarArchiver.FilesetManifestConfig |
addedDirs, addingNewFiles, archiveType, doubleFilePass, duplicate, entries, skipWriting
DEFAULT_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(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(File zipFile)
Create an empty zip file
|
protected void |
finalizeZipOutputStream(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zOut) |
protected static String |
findJarName(String fileName,
String[] classpath)
try to guess the name of the given file.
|
protected static void |
grabFilesAndDirs(String file,
List<String> dirs,
List<String> files)
Grab lists of all root-level files and all directories
contained in the given archive.
|
protected boolean |
hasVirtualFiles() |
protected void |
initZipOutputStream(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream 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(File manifestFile)
The manifest file to use.
|
void |
setManifestEncoding(String manifestEncoding)
Deprecated.
|
protected void |
writeIndexLikeList(List<String> dirs,
List<String> files,
PrintWriter writer)
Writes the directory entries from the first and the filenames
from the second list to the given writer, one entry per line.
|
protected void |
zipFile(InputStream is,
org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zOut,
String vPath,
long lastModified,
File fromArchive,
int mode,
String symlinkDestination)
Overridden from Zip class to deal with manifests and index lists.
|
addParentDirs, addResources, close, copy, execute, getArchiveType, getComment, getEncoding, getZipEntryNames, isCompress, isFileAdded, isFilesonly, isFileUpdated, isInUpdateMode, isRecompressAddedZips, isSupportingForced, revert, setComment, setCompress, setEncoding, setFilesonly, setRecompressAddedZips, setUpdateMode, zipDir, zipFile
addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchiveFinalizer, addDirectory, addDirectory, addDirectory, addDirectory, addFile, addFile, addFileSet, addResource, addResources, addSymlink, addSymlink, asArchiveEntry, asArchiveEntry, asResourceCollection, checkForced, contextualize, createArchive, getArchiveFinalizers, getDefaultDirectoryMode, getDefaultFileMode, getDestFile, getDirectoryMode, getDirs, getDuplicateBehavior, getFileMode, getFiles, getIncludeEmptyDirs, getLogger, getOverrideDirectoryMode, getOverrideFileMode, getRawDefaultDirectoryMode, getRawDefaultFileMode, getResources, isForced, isIgnorePermissions, isUptodate, isUseJvmChmod, runArchiveFinalizers, setArchiveFilters, setArchiveFinalizers, setDefaultDirectoryMode, setDefaultFileMode, setDestFile, setDirectoryMode, setDotFileDirectory, setDuplicateBehavior, setFileMode, setForced, setIgnorePermissions, setIncludeEmptyDirs, setUseJvmChmod, validate
public void setIndex(boolean flag)
flag
- true to create an index@Deprecated public void setManifestEncoding(String manifestEncoding)
public void addConfiguredManifest(Manifest newManifest) throws ManifestException
newManifest
- The new manifestManifestException
- .public void setManifest(File manifestFile) throws ArchiverException
manifestFile
- the manifest file to use.ArchiverException
- .public void setFilesetmanifest(JarArchiver.FilesetManifestConfig config)
config
- setting for found manifest behavior.public void addConfiguredIndexJars(File indexJar)
indexJar
- The indexjarprotected void initZipOutputStream(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zOut) throws IOException, ArchiverException
AbstractZipArchiver
initZipOutputStream
in class AbstractZipArchiver
IOException
ArchiverException
protected boolean hasVirtualFiles()
hasVirtualFiles
in class AbstractArchiver
protected void finalizeZipOutputStream(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zOut) throws IOException, ArchiverException
finalizeZipOutputStream
in class AbstractZipArchiver
IOException
ArchiverException
protected void zipFile(InputStream is, org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode, String symlinkDestination) throws IOException, ArchiverException
zipFile
in class AbstractZipArchiver
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 thisIOException
ArchiverException
protected boolean createEmptyZip(File zipFile) throws ArchiverException
AbstractZipArchiver
createEmptyZip
in class AbstractZipArchiver
zipFile
- The fileArchiverException
protected void cleanUp()
cleanUp
in class AbstractZipArchiver
AbstractZipArchiver.cleanUp()
public void reset()
reset
in class AbstractZipArchiver
AbstractZipArchiver.reset()
protected final void writeIndexLikeList(List<String> dirs, List<String> files, PrintWriter writer)
dirs
- The directoriesfiles
- The fileswriter
- The printwriter ;)protected static String findJarName(String fileName, 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(String file, List<String> dirs, List<String> files) throws IOException
file
- .files
- .dirs
- .IOException
- .Copyright © 2001-2014 Codehaus. All Rights Reserved.