Base class for tasks that build archives in JAR file format.
INDEX_NAME
private static final String INDEX_NAME
The index file name.
MANIFEST_NAME
private static final String MANIFEST_NAME
The manifest file name.
configuredManifest
private Manifest configuredManifest
merged manifests added through addConfiguredManifest
createEmpty
private boolean createEmpty
whether to really create the archive in createEmptyZip, will
get set in getResourcesToAdd.
filesetManifest
private Manifest filesetManifest
merged manifests added through filesets
filesetManifestConfig
private JarArchiver.FilesetManifestConfig filesetManifestConfig
whether to merge fileset manifests;
value is true if filesetmanifest is 'merge' or 'mergewithoutmain'
index
private boolean index
jar index is JDK 1.3+ only
indexJars
private ArrayList indexJars
Path containing jars that shall be indexed in addition to this archive.
manifest
private Manifest manifest
the manifest specified by the 'manifest' attribute *
manifestEncoding
private String manifestEncoding
The encoding to use when reading in a manifest file
manifestFile
private File manifestFile
The file found from the 'manifest' attribute. 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
manifest is looked for in META-INF/MANIFEST.MF
mergeManifestsMain
private boolean mergeManifestsMain
whether to merge the main section of fileset manifests;
value is true if filesetmanifest is 'merge'
originalManifest
private Manifest originalManifest
Manifest of original archive, will be set to null if not in
update mode.
rootEntries
private Vector rootEntries
Stores all files that are in the root of the archive (i.e. that
have a name that doesn't contain a slash) so they can get
listed in the index.
Will not be filled unless the user has asked for an index.
savedConfiguredManifest
private Manifest savedConfiguredManifest
shadow of the above if upToDate check alters the value
addConfiguredIndexJars
public void addConfiguredIndexJars(File indexJar)
addConfiguredManifest
public void addConfiguredManifest(Manifest newManifest)
throws ManifestException
Allows the manifest for the archive file to be provided inline
in the build file rather than in an external file.
cleanUp
protected void cleanUp()
Make sure we don't think we already have a MANIFEST next time this task
gets executed.
- cleanUp in interface AbstractZipArchiver
createIndexList
private void createIndexList(ZipOutputStream zOut)
throws IOException,
ArchiverException
Create the index list to speed up classloading.
This is a JDK 1.3+ specific feature and is enabled by default. See
the JAR index specification for more details.
zOut
- the zip stream representing the jar being built.
filesetManifest
private void filesetManifest(File file,
InputStream is)
throws ArchiverException
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)
throws IOException
Grab lists of all root-level files and all directories
contained in the given archive.
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
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)
throws ArchiverException
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.
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.