PR: MNG-1202

Submitted by: Mark Russell
add support for sections in the manifest


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@321028 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-14 06:08:51 +00:00
parent ff32b5fdaf
commit 731f897a42
3 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,40 @@
package org.apache.maven.archiver;
import java.util.HashMap;
import java.util.Map;
public class ManifestSection {
private String name = null;
private Map manifestEntries = new HashMap();
public void setName( String name ) {
this.name = name;
}
public String getName() {
return name;
}
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;
}
}

View File

@ -17,7 +17,9 @@ package org.apache.maven.archiver;
*/
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -39,6 +41,8 @@ public class MavenArchiveConfiguration
private Map manifestEntries = new HashMap();
private List manifestSections = new ArrayList();
public boolean isCompress()
{
return compress;
@ -102,4 +106,20 @@ public class MavenArchiveConfiguration
{
return manifestEntries;
}
public void addManifestSection( ManifestSection section ) {
manifestSections.add( section );
}
public void addManifestSections( List list ) {
manifestSections.addAll( list );
}
public boolean isManifestSectionsEmpty() {
return manifestSections.isEmpty();
}
public List getManifestSections() {
return manifestSections;
}
}

View File

@ -293,6 +293,32 @@ public class MavenArchiver
}
}
// any custom manifest sections in the archive configuration manifest?
if ( !archiveConfiguration.isManifestSectionsEmpty() )
{
List sections = archiveConfiguration.getManifestSections();
for ( Iterator iter = sections.iterator(); iter.hasNext(); )
{
ManifestSection section = (ManifestSection) iter.next();
Manifest.Section theSection = new Manifest.Section();
theSection.setName( section.getName() );
if( !section.isManifestEntriesEmpty() ) {
Map entries = section.getManifestEntries();
Set keys = entries.keySet();
for ( Iterator it = keys.iterator(); it.hasNext(); )
{
String key = (String) it.next();
String value = (String) entries.get( key );
Manifest.Attribute attr = new Manifest.Attribute( key, value );
theSection.addConfiguredAttribute( attr );
}
}
manifest.addConfiguredSection( theSection );
}
}
// Configure the jar
archiver.addConfiguredManifest( manifest );