PR: MNG-742

Submitted by: Timothy Bennett
Reviewed by: Brett Porter
allow addition of custom entries to the manifest

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@239374 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-08-23 07:31:04 +00:00
parent a4d46f76c1
commit 0bb64a478b
2 changed files with 47 additions and 7 deletions

View File

@ -17,6 +17,8 @@ package org.apache.maven.archiver;
*/
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/**
* Capture common archive configuration.
@ -35,6 +37,8 @@ public class MavenArchiveConfiguration
private ManifestConfiguration manifest;
private Map manifestEntries = new HashMap();
public boolean isCompress()
{
return compress;
@ -78,4 +82,24 @@ public class MavenArchiveConfiguration
{
this.manifest = manifest;
}
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

@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@ -64,7 +65,8 @@ public class MavenArchiver
if ( projectArtifact.isSnapshot() )
{
Manifest.Attribute buildNumberAttr = new Manifest.Attribute( "Build-Number", "" + project.getSnapshotDeploymentBuildNumber() );
Manifest.Attribute buildNumberAttr = new Manifest.Attribute( "Build-Number", "" +
project.getSnapshotDeploymentBuildNumber() );
m.addConfiguredAttribute( buildNumberAttr );
}
@ -275,6 +277,20 @@ public class MavenArchiver
Manifest manifest = getManifest( workingProject, archiveConfiguration.getManifest() );
// 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(); )
{
String key = (String) iter.next();
String value = (String) entries.get( key );
Manifest.Attribute attr = new Manifest.Attribute( key, value );
manifest.addConfiguredAttribute( attr );
}
}
// Configure the jar
archiver.addConfiguredManifest( manifest );