FELIX-4596 : Passing configuration values to the maven-bundle-plugin

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1616413 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 8f0deed..2977716 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -39,6 +39,7 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.jar.Attributes;
@@ -136,10 +137,10 @@
 
     /**
      * Final name of the bundle (without classifier or extension)
-     * 
+     *
      * @parameter expression="${project.build.finalName}"
-     */ 
-    private String finalName; 
+     */
+    private String finalName;
 
     /**
      * Classifier type of the bundle to be installed.  For example, "jdk14".
@@ -458,6 +459,35 @@
     {
         properties.putAll( getDefaultProperties( currentProject ) );
         properties.putAll( transformDirectives( originalInstructions ) );
+
+        // process overrides from project
+        final Set removeProps = new HashSet();
+        final Iterator iter = currentProject.getProperties().entrySet().iterator();
+        while ( iter.hasNext() )
+        {
+            final Map.Entry entry = (Entry) iter.next();
+            final String key = entry.getKey().toString();
+            if ( key.startsWith("BNDExtension-") )
+            {
+                final String oKey = key.substring(13);
+                final String currentValue = properties.getProperty(oKey);
+                if ( currentValue == null )
+                {
+                    properties.put(oKey, entry.getValue());
+                }
+                else
+                {
+                    properties.put(oKey, currentValue + ',' + entry.getValue());
+                }
+                removeProps.add(key);
+            }
+        }
+        final Iterator keyIter = removeProps.iterator();
+        while ( keyIter.hasNext() )
+        {
+            properties.remove(keyIter.next());
+        }
+
         if (properties.getProperty("Bundle-Activator") != null
                 && properties.getProperty("Bundle-Activator").isEmpty())
         {
@@ -483,7 +513,7 @@
         }
 
         Builder builder = new Builder();
-        synchronized ( BundlePlugin.class ) // protect setBase...getBndLastModified which uses static DateFormat 
+        synchronized ( BundlePlugin.class ) // protect setBase...getBndLastModified which uses static DateFormat
         {
             builder.setBase( getBase( currentProject ) );
         }
@@ -1343,7 +1373,7 @@
             // mark all source packages as private by default (can be overridden by export list)
             privatePkgs.put( pkg );
 
-            // we can't export the default package (".") and we shouldn't export internal packages 
+            // we can't export the default package (".") and we shouldn't export internal packages
             String fqn = pkg.getFQN();
             if ( noprivatePackages || !( ".".equals( fqn ) || fqn.contains( ".internal" ) || fqn.contains( ".impl" ) ) )
             {