Applied a refactored patch of FELIX-218 since the original patch was 
removed when merging the plugin with FELIX-199.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@527501 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java b/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
index 982fe58..462ed87 100644
--- a/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
+++ b/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
@@ -111,6 +111,24 @@
   }
  }
 
+ /* transform directives from their XML form to the expected BND syntax (eg. _include becomes -include) */
+ protected Map transformDirectives(Map instructions) {
+  Set removedKeys = new HashSet();
+//System.out.println("BEFORE "+instructions);
+  for (Iterator i = instructions.entrySet().iterator(); i.hasNext();) {
+    final Map.Entry e = (Map.Entry)i.next();
+    final String key = (String)e.getKey();
+    if (key.startsWith("_")) {
+      final String transformedKey = "-"+key.substring(1);
+      instructions.put(transformedKey, e.getValue());
+      removedKeys.add(key);
+    }
+  }
+  instructions.keySet().removeAll(removedKeys);
+//System.out.println("AFTER "+instructions);
+  return instructions;
+ }
+
  protected void execute(MavenProject project, Map instructions, Properties properties, Jar[] classpath) throws MojoExecutionException {
   try {
    File jarFile = new File(getBuildDirectory(), getBundleName(project));
@@ -122,7 +140,7 @@
      properties.put(Analyzer.EXPORT_PACKAGE, bsn + ".*");
    }
 
-   properties.putAll(instructions);
+   properties.putAll(transformDirectives(instructions));
  
    Builder builder = new Builder();
    builder.setBase(baseDir);
diff --git a/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/ManifestPlugin.java b/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/ManifestPlugin.java
index 25f7304..2e1a530 100644
--- a/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/ManifestPlugin.java
+++ b/tools/maven2/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/ManifestPlugin.java
@@ -105,7 +105,7 @@
             props.put( Analyzer.IMPORT_PACKAGE, "*" );
         }
 
-        props.putAll( instructions );
+        props.putAll( transformDirectives( instructions ) );
 
         analyzer.setProperties( props );