Details
-
Improvement
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.0-alpha-3
-
None
-
None
Description
Added functionality to the maven-archiver plugin so that other plugins can add custom manifest entries. Made some fairly minor changes to both MavenArchiveConfiguration.java and MavenArchiver.java. Description of changes below, and I've attached my marked up changes to the M2 HEAD of both files.
MavenArchiveConfiguration.java
=========================
Added the following methods (along with appropriate imports):
private Map manifestEntries = new HashMap();
public void addManifestEntry(Object key, Object value)
{ manifestEntries.put(key, value); }public void addManifestEntries(Map map)
{ manifestEntries.putAll(map); }public boolean isManifestEntriesEmpty()
{ return manifestEntries.isEmpty(); }public Map getManifestEntries()
{ return manifestEntries; }Changes maintain a collection of custom manifest entries stored a name-value pairs. Plugins use the first two methods to add custom manifest entries to the collection. MavenArchiver uses the last two methods to retrieve the set of entries and add them to the archive's manifest.
===============
MavenArchiver.java
===============
In the createArchive() method of MavenArchiver, added the following marked code block to retrieve the custom manifest entries (if any available) from the MavenArchiveConfiguration and add them to the archive's manifest.
Manifest manifest = getManifest( project, archiveConfiguration.getManifest() );
// THIS IS THE START OF THE CODE BLOCK I ADDED
// any custom manifest entries in the archive configuration manifest?
if (!archiveConfiguration.isManifestEntriesEmpty()) {
Map entries = archiveConfiguration.getManifestEntries();
Set keys = entries.keySet();
for (Iterator iter = keys.iterator(); iter.hasNext(); )
}
// THIS IS THE END OF THE CODE BLOCK I ADDED
// Configure the jar
archiver.addConfiguredManifest( manifest );