Package org.gradle.api.java.archives
Interface Manifest
public interface Manifest
Represents the manifest file of a JAR file.
-
Method Summary
Modifier and TypeMethodDescriptionattributes
(Map<String, ?> attributes) Adds content to the main attributes of the manifest.attributes
(Map<String, ?> attributes, String sectionName) Adds content to the given section of the manifest.Specifies other manifests to be merged into this manifest.Specifies other manifests to be merged into this manifest.from
(Object mergePath, Action<ManifestMergeSpec> action) Specifies other manifests to be merged into this manifest.Returns the main attributes of the manifest.Returns a new manifest instance where all the attribute values are expanded (e.g.Returns the sections of the manifest (excluding the main section).Writes the manifest into a file.
-
Method Details
-
getAttributes
Attributes getAttributes()Returns the main attributes of the manifest. -
getSections
Map<String,Attributes> getSections()Returns the sections of the manifest (excluding the main section).- Returns:
- A map with the sections, where the key represents the section name and value the section attributes.
-
attributes
Adds content to the main attributes of the manifest.- Parameters:
attributes
- The values to add to the main attributes. The values can be any object. For evaluating the value objects theirObject.toString()
method is used. This is done lazily either before writing or whengetEffectiveManifest()
is called.- Returns:
- this
- Throws:
ManifestException
- If a key is invalid according to the manifest spec or if a key or value is null.
-
attributes
Adds content to the given section of the manifest.- Parameters:
attributes
- The values to add to the section. The values can be any object. For evaluating the value objects theirObject.toString()
method is used. This is done lazily either before writing or whengetEffectiveManifest()
is called.sectionName
- The name of the section- Returns:
- this
- Throws:
ManifestException
- If a key is invalid according to the manifest spec or if a key or value is null.
-
getEffectiveManifest
Manifest getEffectiveManifest()Returns a new manifest instance where all the attribute values are expanded (e.g. their toString method is called). The returned manifest also contains all the attributes of the to be merged manifests specified infrom(Object...)
. -
writeTo
Writes the manifest into a file. The path's are resolved as defined byProject.files(Object...)
The manifest will be encoded using the character set defined by theJar.getManifestContentCharset()
property.- Parameters:
path
- The path of the file to write the manifest into.- Returns:
- this
-
from
Specifies other manifests to be merged into this manifest. A merge path can either be another instance ofManifest
or a file path as interpreted byProject.file(Object)
. The merge is not happening instantaneously. It happens either before writing or whengetEffectiveManifest()
is called.- Returns:
- this
-
from
Specifies other manifests to be merged into this manifest. A merge path is interpreted as described infrom(Object...)
. The merge is not happening instantaneously. It happens either before writing or whengetEffectiveManifest()
is called. The closure configures the underlyingManifestMergeSpec
.- Returns:
- this
-
from
Specifies other manifests to be merged into this manifest. A merge path is interpreted as described infrom(Object...)
. The merge is not happening instantaneously. It happens either before writing or whengetEffectiveManifest()
is called.- Returns:
- this
- Since:
- 5.0
-