This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push: new f77de570b [MNG-7646] Do not parse the whole reactor unless required by command line options (#963) f77de570b is described below commit f77de570b789d6e0c48c7d5001fdb4d9f663187c Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Thu Jan 26 11:42:23 2023 +0100 [MNG-7646] Do not parse the whole reactor unless required by command line options (#963) --- .../src/main/java/org/apache/maven/DefaultMaven.java | 14 +++++++++++--- .../java/org/apache/maven/graph/DefaultGraphBuilder.java | 8 +++++--- 2 files changed, 16 insertions(+), 6 deletions(-) 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 c6658d2f3..e1880ecae 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<? extends ProjectDependencyGraph> 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<WorkspaceReader> workspaceReaders = new ArrayList<WorkspaceReader>(); + List<WorkspaceReader> 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 9d0683f22..d1512bcc3 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<MavenProject> projects = multiModuleCollectionStrategy.collectProjects(request); - if (!projects.isEmpty()) { - return projects; + if (request.getMakeBehavior() != null || !request.getProjectActivation().isEmpty()) { + List<MavenProject> projects = multiModuleCollectionStrategy.collectProjects(request); + if (!projects.isEmpty()) { + return projects; + } } // 3. Collect projects for explicitly requested POM.