maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] asfgit closed pull request #166: [MNG-6410] Clean suggestion on build resume.
Date Sun, 20 May 2018 19:51:02 GMT
asfgit closed pull request #166: [MNG-6410] Clean suggestion on build resume.
URL: https://github.com/apache/maven/pull/166
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 7b5d97bdbe..a7ff18fbe3 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 @@ private int execute( CliRequest cliRequest )
             {
                 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 "
+                    + getFailedProject( result.getTopologicallySortedProjects(), project
) ).toString() );
             }
 
             if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior()
) )
@@ -1027,6 +1027,32 @@ private int execute( CliRequest cliRequest )
         }
     }
 
+    /**
+     * A helper method to determine value returned for re execution of build.
+     *
+     * By default -rf :artifactId will pick up first module which matches, but quite often
failed project might be later
+     * in build queue. This means that developer will either have to type group id or wait
for build execution of all
+     * modules which were fine, but they are still before one which reported errors.
+     * Since build reactor might contain multiple projects with same artifact id for developer
convenience we print
+     * out groupId:artifactId when there is name clash and :artifactId, if there is no conflict.
+     *
+     * @param mavenProjects Maven projects which are part of build execution.
+     * @param failedProject Project which have failed.
+     * @return Value for -rf flag to restart build exactly from place where it failed.
+     */
+    private String getFailedProject( 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 )
     {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message