Remove local artifacts from install request
[odlparent.git] / karaf-plugin / src / main / java / org / opendaylight / odlparent / FeatureUtil.java
index 01bcecb661efd45c82786f08e4c15ecdf5cfa41b..ff26875ed9fda1488e6e6bc0ab907b916eb8fe45 100644 (file)
@@ -15,6 +15,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -332,7 +333,7 @@ public final class FeatureUtil {
                 Features feature = readFeature(coord);
                 result.add(feature);
                 LOG.debug("findAllFeaturesRecursively() added {}", coord);
-                result.addAll(findAllFeaturesRecursively(readFeature(coord), existingCoords));
+                result.addAll(findAllFeaturesRecursively(feature, existingCoords));
             } else {
                 LOG.trace("findAllFeaturesRecursively() skips known {}", coord);
             }
@@ -371,6 +372,19 @@ public final class FeatureUtil {
         return findAllFeaturesRecursively(features, new LinkedHashSet<>());
     }
 
+    void removeLocalArtifacts(Set<Artifact> artifacts) {
+        if (localRepo != null) {
+            Iterator<Artifact> it = artifacts.iterator();
+            while (it.hasNext()) {
+                Artifact artifact = it.next();
+                if (getFileInLocalRepo(artifact.getFile()) != null) {
+                    LOG.trace("Removing artifact {}", artifact);
+                    it.remove();
+                }
+            }
+        }
+    }
+
     private File getFileInLocalRepo(File file) {
         Path filePath = file.toPath();
         Path parent = filePath.getParent();