Remove local artifacts from install request 74/79474/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 11 Jan 2019 13:50:35 +0000 (14:50 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 11 Jan 2019 13:53:48 +0000 (14:53 +0100)
Since we may have artifacts in the local repository which have
modifications, we do not want to include them in the install
request.

Make sure we exclude such artifacts.

Change-Id: Ib468cac841875e13124ead73c9f8911a29caa2ff
JIRA: ODLPARENT-194
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
karaf-plugin/src/main/java/org/opendaylight/odlparent/FeatureUtil.java
karaf-plugin/src/main/java/org/opendaylight/odlparent/PopulateLocalRepoMojo.java

index 81c7a2aba7c919b931c0c1c290d3ae12e06964c9..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;
@@ -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();
index 8d208ef3018fc6b7bcef9abd99594ad4234bde13..894d2c509e7029085a9899b00106d4b36bb1c0a3 100644 (file)
@@ -121,6 +121,7 @@ public class PopulateLocalRepoMojo extends AbstractMojo {
                 LOG.info("Feature repository discovered recursively: {}", feature.getName());
             }
             Set<Artifact> artifacts = aetherUtil.resolveArtifacts(FeatureUtil.featuresToCoords(features));
+            featureUtil.removeLocalArtifacts(artifacts);
             artifacts.addAll(featureArtifacts);
 
             Map<Gace, String> gaceVersions = new HashMap<>();