Author: mcculls
Date: Wed Jan 30 00:42:48 2008
New Revision: 616684

URL: http://svn.apache.org/viewvc?rev=616684&view=rev
Log:
FELIX-462: Support removal of manifest headers added by the bundleplugin

Modified:
    
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java

Modified: 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=616684&r1=616683&r2=616684&view=diff
==============================================================================
--- 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 (original)
+++ 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 Wed Jan 30 00:42:48 2008
@@ -354,7 +354,8 @@
         doMavenMetadata( currentProject, jar );
         builder.setJar( jar );
 
-        mergeMavenManifest( currentProject, jar, getLog() );
+        String[] removeHeaders = properties.getProperty( 
Analyzer.REMOVE_HEADERS, "" ).split( "," );
+        mergeMavenManifest( currentProject, jar, removeHeaders, getLog() );
 
         return builder;
     }
@@ -402,7 +403,7 @@
     }
 
 
-    protected static void mergeMavenManifest( MavenProject currentProject, Jar 
jar, Log log )
+    protected static void mergeMavenManifest( MavenProject currentProject, Jar 
jar, String[] removeHeaders, Log log )
     {
         try
         {
@@ -450,12 +451,26 @@
                 }
             }
 
+            Attributes mainMavenAttributes = mavenManifest.getMainAttributes();
+            mainMavenAttributes.putValue( "Created-By", "Apache Maven Bundle 
Plugin" );
+
+            // apply -removeheaders to the custom manifest
+            for ( int i = 0; i < removeHeaders.length; i++ )
+            {
+                for ( Iterator j = mainMavenAttributes.keySet().iterator(); 
j.hasNext(); )
+                {
+                    if ( j.next().toString().matches( removeHeaders[i].trim() 
) )
+                    {
+                        j.remove();
+                    }
+                }
+            }
+
             /*
              * Overlay generated bundle manifest with customized entries
              */
             Manifest bundleManifest = jar.getManifest();
-            bundleManifest.getMainAttributes().putAll( 
mavenManifest.getMainAttributes() );
-            bundleManifest.getMainAttributes().putValue( "Created-By", "Apache 
Maven Bundle Plugin" );
+            bundleManifest.getMainAttributes().putAll( mainMavenAttributes );
             bundleManifest.getEntries().putAll( mavenManifest.getEntries() );
             jar.setManifest( bundleManifest );
         }


Reply via email to