FELIX-462: Support removal of manifest headers added by the bundleplugin
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@616684 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index b08485f..95d057c 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -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 );
}