FELIX-2343 - Features maven plugin does not honor local and remote repository overrides


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@944768 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/tooling/features-maven-plugin/pom.xml b/karaf/tooling/features-maven-plugin/pom.xml
index f72e3e7..a4ee251 100644
--- a/karaf/tooling/features-maven-plugin/pom.xml
+++ b/karaf/tooling/features-maven-plugin/pom.xml
@@ -56,10 +56,6 @@
         <artifactId>org.apache.felix.karaf.features.core</artifactId>
       </dependency>
       <dependency>
-        <groupId>org.ops4j.pax.url</groupId>
-        <artifactId>pax-url-mvn</artifactId>
-      </dependency>
-      <dependency>
         <groupId>org.easymock</groupId>
         <artifactId>easymock</artifactId>
         <scope>test</scope>
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 8756321..d84b3fd 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
@@ -33,20 +33,17 @@
 import java.io.FileOutputStream;
 import java.io.FileInputStream;
 import java.net.URI;
-import java.net.URL;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.w3c.dom.*;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.ops4j.pax.url.mvn.Handler;
 import org.xml.sax.SAXException;
 
 /**
@@ -92,7 +89,7 @@
             for (String feature : transitiveFeatures) {
                 bundles.addAll(featuresMap.get(feature).getBundles());
             }
-            System.out.println("Base repo: " + localRepo.getUrl());
+            getLog().info("Base repo: " + localRepo.getUrl());
             for (String bundle : bundles) {
                 if (bundle.startsWith("wrap:")) {
                     bundle = bundle.substring(5);
@@ -118,12 +115,24 @@
                 }
                 String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
                 String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
-                System.out.println("Copy:      " + bundle);
-                copy(new URL(null, bundle, new Handler()).openStream(),
-                     repository,
-                     name,
-                     dir,
-                     new byte[8192]);
+
+                Artifact artifact;
+                try {
+                    artifact = this.factory.createArtifact(groupId, artifactId, version,
+                            (classifier != null ? classifier : ""), type);
+                    getLog().info("Copying bundle: " + bundle);
+                    resolver.resolve(artifact, this.remoteRepos, this.localRepo);
+                    copy(new FileInputStream(artifact.getFile()),
+                         repository,
+                         name,
+                         dir,
+                         new byte[8192]);
+                } catch (ArtifactResolutionException e) {
+                    getLog().error("Can't resolve bundle " + bundle, e);
+                } catch (ArtifactNotFoundException e) {
+                    getLog().error("Can't resolve bundle " + bundle, e);
+                }
+
 
             }
         } catch (MojoExecutionException e) {