diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index e1880ecae4..c610798ba1 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -339,7 +339,7 @@ public class DefaultMaven implements Maven { private void setupWorkspaceReader(MavenSession session, DefaultRepositorySystemSession repoSession) throws ComponentLookupException { // Desired order of precedence for workspace readers before querying the local artifact repositories - List workspaceReaders = new ArrayList<>(); + Set workspaceReaders = new LinkedHashSet<>(); // 1) Reactor workspace reader WorkspaceReader reactorReader = container.lookup(WorkspaceReader.class, ReactorReader.HINT); workspaceReaders.add(reactorReader); @@ -349,13 +349,7 @@ public class DefaultMaven implements Maven { workspaceReaders.add(repoWorkspaceReader); } // 3) .. n) Project-scoped workspace readers - for (WorkspaceReader workspaceReader : - getProjectScopedExtensionComponents(session.getProjects(), WorkspaceReader.class)) { - if (workspaceReaders.contains(workspaceReader)) { - continue; - } - workspaceReaders.add(workspaceReader); - } + workspaceReaders.addAll(getProjectScopedExtensionComponents(session.getProjects(), WorkspaceReader.class)); repoSession.setWorkspaceReader(MavenChainedWorkspaceReader.of(workspaceReaders)); } diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java index 900b5d575a..a4b2a4c868 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -35,6 +35,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Deque; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -69,8 +70,8 @@ class ReactorReader implements MavenWorkspaceReader { public static final String PROJECT_LOCAL_REPO = "project-local-repo"; - private static final Collection COMPILE_PHASE_TYPES = - Arrays.asList("jar", "ejb-client", "war", "rar", "ejb3", "par", "sar", "wsr", "har", "app-client"); + private static final Collection COMPILE_PHASE_TYPES = new HashSet<>( + Arrays.asList("jar", "ejb-client", "war", "rar", "ejb3", "par", "sar", "wsr", "har", "app-client")); private static final Logger LOGGER = LoggerFactory.getLogger(ReactorReader.class);