|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.plexus.logging.AbstractLogEnabled
org.codehaus.plexus.archiver.AbstractArchiver
org.codehaus.plexus.archiver.zip.AbstractZipArchiver
org.codehaus.plexus.archiver.zip.ZipArchiver
org.codehaus.plexus.archiver.jar.JarArchiver
public class JarArchiver
Base class for tasks that build archives in JAR file format.
Nested Class Summary | |
---|---|
static class |
JarArchiver.FilesetManifestConfig
|
Field Summary | |
---|---|
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 |
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.lang.String |
manifestEncoding
The encoding to use when reading in a manifest file |
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 Manifest |
originalManifest
Manifest of original archive, will be set to null if not in update mode. |
private java.util.Vector |
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 |
Fields inherited from class org.codehaus.plexus.archiver.zip.AbstractZipArchiver |
---|
addedDirs, addingNewFiles, archiveType, doubleFilePass, duplicate, entries, skipWriting |
Fields inherited from class org.codehaus.plexus.archiver.AbstractArchiver |
---|
DEFAULT_DIR_MODE, DEFAULT_FILE_MODE |
Fields inherited from interface org.codehaus.plexus.archiver.Archiver |
---|
ROLE |
Constructor Summary | |
---|---|
JarArchiver()
constructor |
Method Summary | |
---|---|
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(ZipOutputStream 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(ZipOutputStream zOut)
method for subclasses to override |
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.Reader r)
|
protected static void |
grabFilesAndDirs(java.lang.String file,
java.util.List dirs,
java.util.List files)
Grab lists of all root-level files and all directories contained in the given archive. |
protected void |
initZipOutputStream(ZipOutputStream 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)
Set whether or not to create an index list for classes. |
protected void |
writeIndexLikeList(java.util.List dirs,
java.util.List 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(ZipOutputStream zOut,
Manifest manifest)
|
protected void |
zipFile(java.io.InputStream is,
ZipOutputStream zOut,
java.lang.String vPath,
long lastModified,
java.io.File fromArchive,
int mode)
Overridden from Zip class to deal with manifests and index lists. |
Methods inherited from class org.codehaus.plexus.archiver.zip.AbstractZipArchiver |
---|
addParentDirs, addResources, createArchive, getArchiveFinalizers, getComment, getDirMode, getEncoding, getFileMode, getResourcesToAdd, getResourcesToUpdate, isCompress, isFilesonly, isInUpdateMode, isRoundUp, isSupportingForced, runArchiveFinalizers, setArchiveFilters, setArchiveFinalizers, setComment, setCompress, setDirMode, setEncoding, setFileMode, setFilesonly, setRoundUp, setUpdateMode, zipDir, zipFile |
Methods inherited from class org.codehaus.plexus.archiver.AbstractArchiver |
---|
addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addArchivedFileSet, addDirectory, addDirectory, addDirectory, addDirectory, addFile, addFile, checkForced, contextualize, getDefaultDirectoryMode, getDefaultFileMode, getDestFile, getDirs, getFiles, getIncludeEmptyDirs, getLogger, isForced, isUptodate, setDefaultDirectoryMode, setDefaultFileMode, setDestFile, setForced, setIncludeEmptyDirs |
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled |
---|
enableLogging, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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.lang.String manifestEncoding
private java.io.File manifestFile
private boolean index
private boolean createEmpty
private java.util.Vector rootEntries
private java.util.ArrayList indexJars
Constructor Detail |
---|
public JarArchiver()
Method Detail |
---|
public void setIndex(boolean flag)
public void setManifestEncoding(java.lang.String manifestEncoding)
public void addConfiguredManifest(Manifest newManifest) throws ManifestException
newManifest
-
ManifestException
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
ArchiverException
private Manifest getManifest(java.io.Reader r) throws ArchiverException
ArchiverException
public void setFilesetmanifest(JarArchiver.FilesetManifestConfig config)
config
- setting for found manifest behavior.public void addConfiguredIndexJars(java.io.File indexJar)
protected void initZipOutputStream(ZipOutputStream zOut) throws java.io.IOException, ArchiverException
AbstractZipArchiver
initZipOutputStream
in class AbstractZipArchiver
java.io.IOException
ArchiverException
private Manifest createManifest() throws ArchiverException
ArchiverException
private void writeManifest(ZipOutputStream zOut, Manifest manifest) throws java.io.IOException, ArchiverException
java.io.IOException
ArchiverException
protected void finalizeZipOutputStream(ZipOutputStream zOut) throws java.io.IOException, ArchiverException
AbstractZipArchiver
finalizeZipOutputStream
in class AbstractZipArchiver
java.io.IOException
ArchiverException
private void createIndexList(ZipOutputStream 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(java.io.InputStream is, ZipOutputStream zOut, java.lang.String vPath, long lastModified, java.io.File fromArchive, int mode) throws java.io.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 this
entry from, will be null if we are not copying from an archive.mode
- the Unix permissions to set.
java.io.IOException
ArchiverException
private void filesetManifest(java.io.File file, java.io.InputStream is) throws ArchiverException
ArchiverException
protected boolean createEmptyZip(java.io.File zipFile) throws ArchiverException
AbstractZipArchiver
createEmptyZip
in class AbstractZipArchiver
ArchiverException
protected void cleanUp()
cleanUp
in class AbstractZipArchiver
AbstractZipArchiver.cleanUp()
public void reset()
reset
in class AbstractZipArchiver
AbstractZipArchiver.reset()
protected final void writeIndexLikeList(java.util.List dirs, java.util.List files, java.io.PrintWriter writer)
protected static final 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.
protected static final void grabFilesAndDirs(java.lang.String file, java.util.List dirs, java.util.List files) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |