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 c6658d2f39..e1880ecae4 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -242,6 +242,13 @@ public class DefaultMaven implements Maven { return addExceptionToResult(result, e); } + try { + WorkspaceReader reactorReader = container.lookup(WorkspaceReader.class, ReactorReader.HINT); + repoSession.setWorkspaceReader(reactorReader); + } catch (ComponentLookupException e) { + return addExceptionToResult(result, e); + } + eventCatapult.fire(ExecutionEvent.Type.ProjectDiscoveryStarted, session, null); Result graphResult = buildGraph(session); @@ -332,12 +339,13 @@ 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(); + List workspaceReaders = new ArrayList<>(); // 1) Reactor workspace reader - workspaceReaders.add(container.lookup(WorkspaceReader.class, ReactorReader.HINT)); + WorkspaceReader reactorReader = container.lookup(WorkspaceReader.class, ReactorReader.HINT); + workspaceReaders.add(reactorReader); // 2) Repository system session-scoped workspace reader WorkspaceReader repoWorkspaceReader = repoSession.getWorkspaceReader(); - if (repoWorkspaceReader != null) { + if (repoWorkspaceReader != null && repoWorkspaceReader != reactorReader) { workspaceReaders.add(repoWorkspaceReader); } // 3) .. n) Project-scoped workspace readers diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java index 9d0683f22e..d1512bcc3b 100644 --- a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java @@ -351,9 +351,11 @@ public class DefaultGraphBuilder implements GraphBuilder { } // 2. Collect projects for all modules in the multi-module project. - List projects = multiModuleCollectionStrategy.collectProjects(request); - if (!projects.isEmpty()) { - return projects; + if (request.getMakeBehavior() != null || !request.getProjectActivation().isEmpty()) { + List projects = multiModuleCollectionStrategy.collectProjects(request); + if (!projects.isEmpty()) { + return projects; + } } // 3. Collect projects for explicitly requested POM.