This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MNG-4660 in repository https://gitbox.apache.org/repos/asf/maven.git
commit 3360bba73ed4570a7a0bc05f114ba254cc4812b8 Author: Martin Kanters <martin.kant...@infosupport.com> AuthorDate: Thu Mar 26 18:09:28 2020 +0100 Replace checking if the project has the lifecyclePhase "validate" by checking if the project consists in the reactor. --- maven-core/src/main/java/org/apache/maven/ReactorReader.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 0d28a3a..ddc74f7 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -66,6 +66,8 @@ class ReactorReader private Logger logger; + private MavenSession session; + private Map<String, MavenProject> projectsByGAV; private Map<String, List<MavenProject>> projectsByGA; @@ -76,6 +78,7 @@ class ReactorReader ReactorReader( MavenSession session, Logger logger ) { this.logger = logger; + this.session = session; this.projectsByGAV = new HashMap<>( session.getAllProjects().size() * 2 ); session.getAllProjects().forEach( project -> { @@ -196,15 +199,15 @@ class ReactorReader String type = artifact.getProperty( "type", "" ); File outputDirectory = new File( project.getBuild().getOutputDirectory() ); - // Check if the target project is being built during this session, and if we can expect any output. + // Check if the project is being built during this session, and if we can expect any output. // There is no need to check if the build has created any outputs, see MNG-2222. boolean projectCompiledDuringThisSession = project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ); - // Check if the target project lacks 'validate' so we know it's not part of the build at all. If so, we - // check if a possible earlier Maven invocation produced some output for that project. + // Check if the project is part of the session (not filtered by -pl, -rf, etc). If so, we check + // if a possible earlier Maven invocation produced some output for that project which we can use. boolean projectHasOutputFromPreviousSession - = !project.hasLifecyclePhase( "validate" ) && outputDirectory.exists(); + = !session.getProjects().contains( project ) && outputDirectory.exists(); if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession ) {