MartinKanters commented on a change in pull request #373:
URL: https://github.com/apache/maven/pull/373#discussion_r487525206
##########
File path:
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##########
@@ -361,76 +406,35 @@ private File getReactorDirectory( MavenExecutionRequest
request )
throws ProjectBuildingException
{
MavenExecutionRequest request = session.getRequest();
-
request.getProjectBuildingRequest().setRepositorySession(
session.getRepositorySession() );
- List<MavenProject> projects = new ArrayList<>();
+ List<ProjectCollectionStrategy> projectCollectionStrategies =
Arrays.asList(
+ projectlessCollectionStrategy, // 1. Collect project for
invocation without a POM.
+ multiModuleCollectionStrategy, // 2. Collect projects for all
modules in the multi-module project.
+ requestPomCollectionStrategy // 3. Collect projects for
explicitly requested POM.
+ );
- // We have no POM file.
- //
- if ( request.getPom() == null )
+ for ( ProjectCollectionStrategy strategy : projectCollectionStrategies
)
Review comment:
This logic has indeed changed, with the main reasoning being that it is
possible that the second strategy [1] fails and that we will have to fallback
on the third strategy [2]. The second strategy can fail when it finds that the
multiModuleProjectDirectory is incorrect; aka [not linking to the actual root
of the multi-module
project](https://github.com/apache/maven/pull/373/files#diff-cdc90272b007188972c28fe364870fb1R73).
It can also fail when a module is collected which [requires a plugin in the
same
multi-module](https://github.com/apache/maven/pull/373/files#diff-cdc90272b007188972c28fe364870fb1R133).
The for loop will break when it found the last strategy to be successful
(meaning: one or more projects have been collected).
But maybe the for loop structuring does not improve readability, so we could
rework it into an if-else structure as you suggest. WDYT @mthmulders ?
[1] The second strategy is most of what this PR is about: collecting
projects based on the multiModuleProjectDirectory/pom.xml.
[2] The third strategy is collecting projects based on the pom in the
request (basically the current 3.6.3 behavior).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]