Package org.apache.tools.ant.taskdefs
Class Manifest
java.lang.Object
org.apache.tools.ant.taskdefs.Manifest
Holds the data of a jar manifest.
Manifests are processed according to the
Jar
file specification.
Specifically, a manifest element consists of
a set of attributes and sections. These sections in turn may contain
attributes. Note in particular that this may result in manifest lines
greater than 72 bytes being wrapped and continued on the next
line. If an application can not handle the continuation mechanism, it
is a defect in the application, not this task.
- Since:
- Ant 1.4
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An attribute for the manifest.static class
A manifest section - you can nest attribute elements into sections. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The Class-Path Header is special - it can be duplicatedstatic final String
The From Header is disallowed in a Manifeststatic final String
The standard manifest version headerstatic final String
The Name Attribute is the first in a named sectionstatic final String
The standard Signature Version headerstatic final String
Default Manifest version if one is not specifiedstatic final String
The End-Of-Line marker in manifestsstatic final String
Error for attributesstatic final Charset
Charset to be used for JAR files.static final String
Deprecated.static final int
The max length of a line in a Manifeststatic final int
Max length of a line section which is continued. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfiguredAttribute
(Manifest.Attribute attribute) Add an attribute to the manifest - it is added to the main section.void
addConfiguredSection
(Manifest.Section section) Add a section to the manifestboolean
static Manifest
Construct a manifest from Ant's default manifest file.Get the main section of the manifestGet the version of the manifestgetSection
(String name) Get a particular section from the manifestGet the section names in this manifest.Get the warnings for this manifest.int
hashCode()
void
Merge the contents of the given manifest into this manifest without merging Class-Path attributes.void
Merge the contents of the given manifest into this manifest without merging Class-Path attributes.void
Merge the contents of the given manifest into this manifesttoString()
Convert the manifest to its string representationvoid
write
(PrintWriter writer) Write the manifest out to a print writer without flattening multi-values attributes (i.e.void
write
(PrintWriter writer, boolean flatten) Write the manifest out to a print writer.
-
Field Details
-
ATTRIBUTE_MANIFEST_VERSION
The standard manifest version header- See Also:
-
ATTRIBUTE_SIGNATURE_VERSION
The standard Signature Version header- See Also:
-
ATTRIBUTE_NAME
The Name Attribute is the first in a named section- See Also:
-
ATTRIBUTE_FROM
-
ATTRIBUTE_CLASSPATH
The Class-Path Header is special - it can be duplicated- See Also:
-
DEFAULT_MANIFEST_VERSION
Default Manifest version if one is not specified- See Also:
-
MAX_LINE_LENGTH
public static final int MAX_LINE_LENGTHThe max length of a line in a Manifest- See Also:
-
MAX_SECTION_LENGTH
public static final int MAX_SECTION_LENGTHMax length of a line section which is continued. Need to allow for the CRLF.- See Also:
-
EOL
-
ERROR_FROM_FORBIDDEN
-
JAR_CHARSET
Charset to be used for JAR files. -
JAR_ENCODING
-
-
Constructor Details
-
Manifest
public Manifest()Construct an empty manifest -
Manifest
Read a manifest file from the given reader- Parameters:
r
- is the reader from which the Manifest is read- Throws:
ManifestException
- if the manifest is not valid according to the JAR specIOException
- if the manifest cannot be read from the reader.
-
-
Method Details
-
getDefaultManifest
Construct a manifest from Ant's default manifest file.- Returns:
- the default manifest.
- Throws:
BuildException
- if there is a problem loading the default manifest
-
addConfiguredSection
Add a section to the manifest- Parameters:
section
- the manifest section to be added- Throws:
ManifestException
- if the secti0on is not valid.
-
addConfiguredAttribute
Add an attribute to the manifest - it is added to the main section.- Parameters:
attribute
- the attribute to be added.- Throws:
ManifestException
- if the attribute is not valid.
-
merge
Merge the contents of the given manifest into this manifest without merging Class-Path attributes.- Parameters:
other
- the Manifest to be merged with this one.- Throws:
ManifestException
- if there is a problem merging the manifest according to the Manifest spec.
-
merge
Merge the contents of the given manifest into this manifest without merging Class-Path attributes.- Parameters:
other
- the Manifest to be merged with this one.overwriteMain
- whether to overwrite the main section of the current manifest- Throws:
ManifestException
- if there is a problem merging the manifest according to the Manifest spec.
-
merge
public void merge(Manifest other, boolean overwriteMain, boolean mergeClassPaths) throws ManifestException Merge the contents of the given manifest into this manifest- Parameters:
other
- the Manifest to be merged with this one.overwriteMain
- whether to overwrite the main section of the current manifestmergeClassPaths
- whether Class-Path attributes should be merged.- Throws:
ManifestException
- if there is a problem merging the manifest according to the Manifest spec.- Since:
- Ant 1.8.0
-
write
Write the manifest out to a print writer without flattening multi-values attributes (i.e. Class-Path).- Parameters:
writer
- the Writer to which the manifest is written- Throws:
IOException
- if the manifest cannot be written
-
write
Write the manifest out to a print writer.- Parameters:
writer
- the Writer to which the manifest is writtenflatten
- whether to collapse multi-valued attributes (i.e. potentially Class-Path) Class-Path into a single attribute.- Throws:
IOException
- if the manifest cannot be written- Since:
- Ant 1.8.0
-
toString
-
getWarnings
Get the warnings for this manifest.- Returns:
- an enumeration of warning strings
-
hashCode
-
equals
-
getManifestVersion
Get the version of the manifest- Returns:
- the manifest's version string
-
getMainSection
Get the main section of the manifest- Returns:
- the main section of the manifest
-
getSection
Get a particular section from the manifest- Parameters:
name
- the name of the section desired.- Returns:
- the specified section or null if that section does not exist in the manifest
-
getSectionNames
Get the section names in this manifest.- Returns:
- an Enumeration of section names
-