org.codehaus.plexus.archiver.jar

Class JarArchiver

public class JarArchiver extends ZipArchiver

Base class for tasks that build archives in JAR file format.

Version: $Revision: 7189 $ $Date: 2008-02-02 03:08:42 +0200 (Sat, 02 Feb 2008) $

Nested Class Summary
static classJarArchiver.FilesetManifestConfig
Constructor Summary
JarArchiver()
constructor
Method Summary
voidaddConfiguredIndexJars(File indexJar)
voidaddConfiguredManifest(Manifest newManifest)
Allows the manifest for the archive file to be provided inline in the build file rather than in an external file.
protected voidcleanUp()
Make sure we don't think we already have a MANIFEST next time this task gets executed.
protected booleancreateEmptyZip(File zipFile)
protected voidfinalizeZipOutputStream(ZipOutputStream zOut)
protected static StringfindJarName(String fileName, String[] classpath)
try to guess the name of the given file.
protected static voidgrabFilesAndDirs(String file, List dirs, List files)
Grab lists of all root-level files and all directories contained in the given archive.
protected booleanhasVirtualFiles()
protected voidinitZipOutputStream(ZipOutputStream zOut)
voidreset()
reset to default values.
voidsetFilesetmanifest(JarArchiver.FilesetManifestConfig config)
Behavior when a Manifest is found in a zipfileset or zipgroupfileset file.
voidsetIndex(boolean flag)
Set whether or not to create an index list for classes.
voidsetManifest(File manifestFile)
The manifest file to use.
voidsetManifestEncoding(String manifestEncoding)
Set whether or not to create an index list for classes.
protected voidwriteIndexLikeList(List dirs, List 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 voidzipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode)
Overridden from Zip class to deal with manifests and index lists.

Constructor Detail

JarArchiver

public JarArchiver()
constructor

Method Detail

addConfiguredIndexJars

public void addConfiguredIndexJars(File indexJar)

addConfiguredManifest

public 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.

Parameters: newManifest

Throws: ManifestException

cleanUp

protected void cleanUp()
Make sure we don't think we already have a MANIFEST next time this task gets executed.

See Also: ZipArchiver

createEmptyZip

protected boolean createEmptyZip(File zipFile)

finalizeZipOutputStream

protected void finalizeZipOutputStream(ZipOutputStream zOut)

findJarName

protected static final String findJarName(String fileName, String[] classpath)
try to guess the name of the given file.

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.

grabFilesAndDirs

protected static final void grabFilesAndDirs(String file, List dirs, List files)
Grab lists of all root-level files and all directories contained in the given archive.

hasVirtualFiles

protected boolean hasVirtualFiles()

initZipOutputStream

protected void initZipOutputStream(ZipOutputStream zOut)

reset

public void reset()
reset to default values.

See Also: ZipArchiver

setFilesetmanifest

public void setFilesetmanifest(JarArchiver.FilesetManifestConfig config)
Behavior when a Manifest is found in a zipfileset or zipgroupfileset file. Valid values are "skip", "merge", and "mergewithoutmain". "merge" will merge all of manifests together, and merge this into any other specified manifests. "mergewithoutmain" merges everything but the Main section of the manifests. Default value is "skip".

Note: if this attribute's value is not "skip", the created jar will not be readable by using java.util.jar.JarInputStream

Parameters: config setting for found manifest behavior.

setIndex

public void setIndex(boolean flag)
Set whether or not to create an index list for classes. This may speed up classloading in some cases.

setManifest

public void setManifest(File manifestFile)
The manifest file to use. This can be either the location of a manifest, or the name of a jar added through a fileset. If its the name of an added jar, the task expects the manifest to be in the jar at META-INF/MANIFEST.MF.

Parameters: manifestFile the manifest file to use.

setManifestEncoding

public void setManifestEncoding(String manifestEncoding)
Set whether or not to create an index list for classes. This may speed up classloading in some cases.

writeIndexLikeList

protected final void writeIndexLikeList(List dirs, List 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.

zipFile

protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode)
Overridden from Zip class to deal with manifests and index lists.
Copyright © 2001-2009 Codehaus. All Rights Reserved.