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 SummaryNested ClassesModifier and TypeClassDescriptionstatic classAn attribute for the manifest.static classA manifest section - you can nest attribute elements into sections.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe Class-Path Header is special - it can be duplicatedstatic final StringThe From Header is disallowed in a Manifeststatic final StringThe standard manifest version headerstatic final StringThe Name Attribute is the first in a named sectionstatic final StringThe standard Signature Version headerstatic final StringDefault Manifest version if one is not specifiedstatic final StringThe End-Of-Line marker in manifestsstatic final StringError for attributesstatic final CharsetCharset to be used for JAR files.static final StringDeprecated.static final intThe max length of a line in a Manifeststatic final intMax length of a line section which is continued.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddConfiguredAttribute(Manifest.Attribute attribute) Add an attribute to the manifest - it is added to the main section.voidaddConfiguredSection(Manifest.Section section) Add a section to the manifestbooleanstatic ManifestConstruct 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.inthashCode()voidMerge the contents of the given manifest into this manifest without merging Class-Path attributes.voidMerge the contents of the given manifest into this manifest without merging Class-Path attributes.voidMerge the contents of the given manifest into this manifesttoString()Convert the manifest to its string representationvoidwrite(PrintWriter writer) Write the manifest out to a print writer without flattening multi-values attributes (i.e.voidwrite(PrintWriter writer, boolean flatten) Write the manifest out to a print writer.
- 
Field Details- 
ATTRIBUTE_MANIFEST_VERSIONThe standard manifest version header- See Also:
 
- 
ATTRIBUTE_SIGNATURE_VERSIONThe standard Signature Version header- See Also:
 
- 
ATTRIBUTE_NAMEThe Name Attribute is the first in a named section- See Also:
 
- 
ATTRIBUTE_FROMThe From Header is disallowed in a Manifest- See Also:
 
- 
ATTRIBUTE_CLASSPATHThe Class-Path Header is special - it can be duplicated- See Also:
 
- 
DEFAULT_MANIFEST_VERSIONDefault Manifest version if one is not specified- See Also:
 
- 
MAX_LINE_LENGTHpublic static final int MAX_LINE_LENGTHThe max length of a line in a Manifest- See Also:
 
- 
MAX_SECTION_LENGTHpublic static final int MAX_SECTION_LENGTHMax length of a line section which is continued. Need to allow for the CRLF.- See Also:
 
- 
EOLThe End-Of-Line marker in manifests- See Also:
 
- 
ERROR_FROM_FORBIDDENError for attributes- See Also:
 
- 
JAR_CHARSETCharset to be used for JAR files.
- 
JAR_ENCODINGDeprecated.Encoding to be used for JAR files.
 
- 
- 
Constructor Details- 
Manifestpublic Manifest()Construct an empty manifest
- 
ManifestRead 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 spec
- IOException- if the manifest cannot be read from the reader.
 
 
- 
- 
Method Details- 
getDefaultManifestConstruct a manifest from Ant's default manifest file.- Returns:
- the default manifest.
- Throws:
- BuildException- if there is a problem loading the default manifest
 
- 
addConfiguredSectionAdd a section to the manifest- Parameters:
- section- the manifest section to be added
- Throws:
- ManifestException- if the secti0on is not valid.
 
- 
addConfiguredAttributeAdd 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.
 
- 
mergeMerge 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.
 
- 
mergeMerge 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.
 
- 
mergepublic 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 manifest
- mergeClassPaths- 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
 
- 
writeWrite 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
 
- 
writeWrite the manifest out to a print writer.- Parameters:
- writer- the Writer to which the manifest is written
- flatten- 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
 
- 
toStringConvert the manifest to its string representation
- 
getWarningsGet the warnings for this manifest.- Returns:
- an enumeration of warning strings
 
- 
hashCodepublic int hashCode()
- 
equals
- 
getManifestVersionGet the version of the manifest- Returns:
- the manifest's version string
 
- 
getMainSectionGet the main section of the manifest- Returns:
- the main section of the manifest
 
- 
getSectionGet 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
 
- 
getSectionNamesGet the section names in this manifest.- Returns:
- an Enumeration of section names
 
 
-