You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2018/05/20 19:50:48 UTC

[maven] branch master updated: [MNG-6410] Add groupId to --resume-from suggestion if artifactId is not unique in reactor

This is an automated email from the ASF dual-hosted git repository.

michaelo 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 864d180  [MNG-6410] Add groupId to --resume-from suggestion if artifactId is not unique in reactor
864d180 is described below

commit 864d180edf7b66b07e2e3fc08709b5cb1e4f051c
Author: Ɓukasz Dywicki <lu...@code-house.org>
AuthorDate: Fri May 11 15:46:05 2018 +0200

    [MNG-6410] Add groupId to --resume-from suggestion if artifactId is not unique in reactor
    
    This closes #166
---
 .../main/java/org/apache/maven/cli/MavenCli.java   | 33 ++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 7b5d97b..ca8e040 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -1006,8 +1006,8 @@ public class MavenCli
             {
                 slf4jLogger.error( "" );
                 slf4jLogger.error( "After correcting the problems, you can resume the build with the command" );
-                slf4jLogger.error( buffer().a( "  " ).strong( "mvn <goals> -rf :"
-                                + project.getArtifactId() ).toString() );
+                slf4jLogger.error( buffer().a( "  " ).strong( "mvn <goals> -rf "
+                    + getResumeFrom( result.getTopologicallySortedProjects(), project ) ).toString() );
             }
 
             if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior() ) )
@@ -1027,6 +1027,35 @@ public class MavenCli
         }
     }
 
+    /**
+     * A helper method to determine the value to resume the build with {@code -rf} taking into account the
+     * edge case where multiple modules in the reactor have the same artifactId.
+     * <p>
+     * {@code -rf :artifactId} will pick up the first module which matches, but when multiple modules in the
+     * reactor have the same artifactId, effective failed module might be later in build reactor.
+     * This means that developer will either have to type groupId or wait for build execution of all modules
+     * which were fine, but they are still before one which reported errors.
+     * <p>Then the returned value is {@code groupId:artifactId} when there is a name clash and
+     * {@code :artifactId} if there is no conflict.
+     *
+     * @param mavenProjects Maven projects which are part of build execution.
+     * @param failedProject Project which has failed.
+     * @return Value for -rf flag to resume build exactly from place where it failed ({@code :artifactId} in
+     *    general and {@code groupId:artifactId} when there is a name clash).
+     */
+    private String getResumeFrom( List<MavenProject> mavenProjects, MavenProject failedProject )
+    {
+        for ( MavenProject buildProject : mavenProjects )
+        {
+            if ( failedProject.getArtifactId().equals( buildProject.getArtifactId() ) && !failedProject.equals(
+                    buildProject ) )
+            {
+                return failedProject.getGroupId() + ":" + failedProject.getArtifactId();
+            }
+        }
+        return ":" + failedProject.getArtifactId();
+    }
+
     private void logSummary( ExceptionSummary summary, Map<String, String> references, String indent,
                              boolean showErrors )
     {

-- 
To stop receiving notification emails like this one, please contact
michaelo@apache.org.