You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/03/28 10:29:37 UTC

[maven] 12/14: More sophisticated rules for determining project artifact

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 83dd0ee3cc9ee09dc801215bccc1943911e222ff
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Thu Mar 26 13:59:38 2020 +0100

    More sophisticated rules for determining project artifact
    
    It now properly distinguishes between two situations:
    1. project artifact has been built during earlier Maven session
    2. project artifact has been built during this session
---
 .../src/main/java/org/apache/maven/ReactorReader.java   | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 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 7c85668..71e70b9 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -194,9 +194,22 @@ class ReactorReader
             else
             {
                 String type = artifact.getProperty( "type", "" );
-                if ( COMPILE_PHASE_TYPES.contains( 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.
+                // 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.
+                boolean projectHasOutputFromPreviousSession
+                        = !project.hasLifecyclePhase( "validate" ) && outputDirectory.exists();
+
+                if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession )
                 {
-                    return new File( project.getBuild().getOutputDirectory() );
+                    // If the target project is not part of the build,
+                    return outputDirectory;
                 }
             }
         }