Using Set<>() for contains()

This closes #998
This commit is contained in:
Andrey Bruykhov 2023-02-13 22:46:54 +03:00 committed by Michael Osipov
parent 009ec5dc41
commit f7d3e30d10
2 changed files with 5 additions and 10 deletions

View File

@ -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<WorkspaceReader> workspaceReaders = new ArrayList<>();
Set<WorkspaceReader> 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));
}

View File

@ -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<String> COMPILE_PHASE_TYPES =
Arrays.asList("jar", "ejb-client", "war", "rar", "ejb3", "par", "sar", "wsr", "har", "app-client");
private static final Collection<String> 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);