belingueres commented on code in PR #281:
URL: https://github.com/apache/maven/pull/281#discussion_r4241874644


##########
impl/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java:
##########
@@ -65,6 +67,46 @@
  */
 public class RepositoryUtils {
 
+    @FunctionalInterface
+    private interface ArtifactOrderingStrategy {
+        void apply(
+                Collection<org.apache.maven.artifact.Artifact> artifacts,
+                Collection<? extends DependencyNode> nodes,
+                List<String> trail,
+                DependencyFilter filter);
+    }
+
+    public enum ArtifactOrdering {
+        /**
+         * Depth-first traversal of the dependency graph to convert nodes to 
artifacts. This is the original behavior.
+         */
+        DFS(RepositoryUtils::toArtifactsDFS),
+        /**
+         * Breadth-first traversal of the dependency graph, using a List of 
Lists to store artifacts by depth, and a stack to keep the dependency trail. 
This is the new behavior.
+         */
+        BFS(RepositoryUtils::toArtifactsBFS);
+
+        private ArtifactOrderingStrategy strategy;
+
+        ArtifactOrdering(ArtifactOrderingStrategy strategy) {
+            this.strategy = strategy;
+        }
+
+        public ArtifactOrderingStrategy getStrategy() {
+            return strategy;
+        }
+    }
+
+    private static ArtifactOrdering artifactOrdering = ArtifactOrdering.BFS;

Review Comment:
   To avoid thread-safety issues altogether, perhaps we should avoid the static 
artifactOrdering variable, and let the client pass the ArtifactOrdering as a 
parameter to the toArtifact method, and leave (or deprecate?) the current 
toArtifact with the current DFS ordering hardcoded? WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to