You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/08/23 09:31:08 UTC

svn commit: r239374 - in /maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver: MavenArchiveConfiguration.java MavenArchiver.java

Author: brett
Date: Tue Aug 23 00:31:04 2005
New Revision: 239374

URL: http://svn.apache.org/viewcvs?rev=239374&view=rev
Log:
PR: MNG-742
Submitted by: Timothy Bennett
Reviewed by: Brett Porter
allow addition of custom entries to the manifest

Modified:
    maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
    maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java

Modified: maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java?rev=239374&r1=239373&r2=239374&view=diff
==============================================================================
--- maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java (original)
+++ maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java Tue Aug 23 00:31:04 2005
@@ -17,6 +17,8 @@
  */
 
 import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Capture common archive configuration.
@@ -35,6 +37,8 @@
 
     private ManifestConfiguration manifest;
 
+    private Map manifestEntries = new HashMap();
+
     public boolean isCompress()
     {
         return compress;
@@ -77,5 +81,25 @@
     public void setManifest( ManifestConfiguration manifest )
     {
         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;
     }
 }

Modified: maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java?rev=239374&r1=239373&r2=239374&view=diff
==============================================================================
--- maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java (original)
+++ maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java Tue Aug 23 00:31:04 2005
@@ -32,6 +32,7 @@
 import java.io.OutputStream;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
@@ -42,7 +43,7 @@
 public class MavenArchiver
 {
     private JarArchiver archiver = new JarArchiver();
-    
+
     private File archiveFile;
 
     /**
@@ -59,12 +60,13 @@
         m.addConfiguredAttribute( buildAttr );
         Manifest.Attribute createdAttr = new Manifest.Attribute( "Created-By", "Apache Maven" );
         m.addConfiguredAttribute( createdAttr );
-        
+
         Artifact projectArtifact = project.getArtifact();
-        
+
         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 );
         }
 
@@ -222,16 +224,16 @@
         // top-level POM elements so that applications that wish to access
         // POM information without the use of maven tools can do so.
         // ----------------------------------------------------------------------
-        
+
         // we have to clone the project instance so we can write out the pom with the deployment version,
         // without impacting the main project instance...
         MavenProject workingProject = new MavenProject( project );
-        
+
         if ( workingProject.getArtifact().isSnapshot() )
         {
             workingProject.setVersion( workingProject.getSnapshotDeploymentVersion() );
         }
-        
+
         String groupId = workingProject.getGroupId();
 
         String artifactId = workingProject.getArtifactId();
@@ -274,6 +276,20 @@
         }
 
         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 );



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org