FELIX-2329: Improve the URL handling  in features-maven-plugin regarding the add-features-to-repo goal

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@945101 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
index d84b3fd..ae7c6ec 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
@@ -74,6 +74,11 @@
      */
     private File repository;
 
+    /**
+     * @parameter
+     */
+    private boolean skipNonMavenProtocols = true;
+
     public void execute() throws MojoExecutionException, MojoFailureException {
         try {
             Map<String, Feature> featuresMap = new HashMap<String, Feature>();
@@ -91,12 +96,32 @@
             }
             getLog().info("Base repo: " + localRepo.getUrl());
             for (String bundle : bundles) {
-                if (bundle.startsWith("wrap:")) {
-                    bundle = bundle.substring(5);
-                }
-                if (!bundle.startsWith("mvn:")) {
+                final int index = bundle.indexOf("mvn:");
+                if (index < 0) {
+                    if (skipNonMavenProtocols) {
+                        continue;
+                    }
                     throw new MojoExecutionException("Bundle url is not a maven url: " + bundle);
                 }
+                else {
+                    bundle = bundle.substring(index);
+                }
+                // Truncate the URL when a '#' or a '?' is encountered
+                final int index1 = bundle.indexOf('?');
+                final int index2 = bundle.indexOf('#');
+                int endIndex = -1;
+                if (index1 > 0) {
+                     if (index2 > 0) {
+                         endIndex = Math.min(index1, index2);
+                     } else {
+                         endIndex = index1;
+                     }
+                } else if (index2 > 0) {
+                    endIndex = index2;
+                }
+                if (endIndex >= 0) {
+                    bundle = bundle.substring(0, endIndex);
+                }
                               
                 String[] parts = bundle.substring("mvn:".length()).split("/");
                 String groupId = parts[0];