You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2018/10/21 14:36:12 UTC

[maven] branch MNG-5693 updated (39d3bd8 -> 79230ad)

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

slachiewicz pushed a change to branch MNG-5693
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard 39d3bd8  [MNG-5693] Change logging of MojoExceptions to console
     add 0345cd1  [MNG-6489] Upgrade Maven Resolver to 1.3.0
     add 13a0a5f  [MNG-6491] upgraded commons-lang3 to fix tests failure with JDK 10/11
     add 6e619a1  [MNG-6496] Upgrade Maven Resolver to 1.3.1
     add 42c77a7  Repair Jenkins job - add a full path to workspace when run on Windows
     add 23f5c88  [MNG-6391] - Printout version of last built module in reactor build
     new 79230ad  [MNG-5693] Change logging of MojoExceptions to console

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (39d3bd8)
            \
             N -- N -- N   refs/heads/MNG-5693 (79230ad)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Jenkinsfile                                        |  4 +--
 .../maven/cli/event/ExecutionEventLogger.java      | 38 ++++++++++++++++++----
 maven-resolver-provider/pom.xml                    |  9 +++++
 .../internal/DefaultArtifactDescriptorReader.java  | 24 +-------------
 .../internal/DefaultVersionRangeResolver.java      | 22 +------------
 .../internal/DefaultVersionResolver.java           | 22 +------------
 pom.xml                                            |  4 +--
 7 files changed, 48 insertions(+), 75 deletions(-)


[maven] 01/01: [MNG-5693] Change logging of MojoExceptions to console

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-5693
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 79230adb743361550f02b75e28d69036b8d5abe7
Author: Sylwester Lachiewicz <sl...@gmail.com>
AuthorDate: Wed Oct 10 11:48:10 2018 +0200

    [MNG-5693] Change logging of MojoExceptions to console
    
    MojoExecutionException and MojoFailureException should never refer to a wikipage anymore.
---
 .../maven/exception/DefaultExceptionHandler.java   | 103 +--------------------
 .../exception/DefaultExceptionHandlerTest.java     |  16 ++--
 .../main/java/org/apache/maven/cli/MavenCli.java   |  12 ---
 3 files changed, 9 insertions(+), 122 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java
index 2a86667..86f272e 100644
--- a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java
+++ b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java
@@ -19,20 +19,13 @@ package org.apache.maven.exception;
  * under the License.
  */
 
-import java.io.IOException;
-import java.net.ConnectException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.maven.lifecycle.LifecycleExecutionException;
 import org.apache.maven.model.building.ModelProblem;
 import org.apache.maven.model.building.ModelProblemUtils;
 import org.apache.maven.plugin.AbstractMojoExecutionException;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.PluginContainerException;
-import org.apache.maven.plugin.PluginExecutionException;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.ProjectBuildingResult;
 import org.codehaus.plexus.component.annotations.Component;
@@ -98,8 +91,6 @@ public class DefaultExceptionHandler
 
     private ExceptionSummary handle( String message, Throwable exception )
     {
-        String reference = getReference( exception );
-
         List<ExceptionSummary> children = null;
 
         if ( exception instanceof ProjectBuildingException )
@@ -124,7 +115,7 @@ public class DefaultExceptionHandler
             message = getMessage( message, exception );
         }
 
-        return new ExceptionSummary( exception, message, reference, children );
+        return new ExceptionSummary( exception, message, null, children );
     }
 
     private ExceptionSummary handle( ProjectBuildingResult result )
@@ -173,98 +164,6 @@ public class DefaultExceptionHandler
         }
     }
 
-    private String getReference( Throwable exception )
-    {
-        String reference = "";
-
-        if ( exception != null )
-        {
-            if ( exception instanceof MojoExecutionException )
-            {
-                reference = MojoExecutionException.class.getSimpleName();
-
-                Throwable cause = exception.getCause();
-                if ( cause instanceof IOException )
-                {
-                    cause = cause.getCause();
-                    if ( cause instanceof ConnectException )
-                    {
-                        reference = ConnectException.class.getSimpleName();
-                    }
-                }
-            }
-            else if ( exception instanceof MojoFailureException )
-            {
-                reference = MojoFailureException.class.getSimpleName();
-            }
-            else if ( exception instanceof LinkageError )
-            {
-                reference = LinkageError.class.getSimpleName();
-            }
-            else if ( exception instanceof PluginExecutionException )
-            {
-                Throwable cause = exception.getCause();
-
-                if ( cause instanceof PluginContainerException )
-                {
-                    Throwable cause2 = cause.getCause();
-
-                    if ( cause2 instanceof NoClassDefFoundError
-                        && cause2.getMessage().contains( "org/sonatype/aether/" ) )
-                    {
-                        reference = "AetherClassNotFound";
-                    }
-                }
-
-                if ( StringUtils.isEmpty( reference ) )
-                {
-                    reference = getReference( cause );
-                }
-
-                if ( StringUtils.isEmpty( reference ) )
-                {
-                    reference = exception.getClass().getSimpleName();
-                }
-            }
-            else if ( exception instanceof LifecycleExecutionException )
-            {
-                reference = getReference( exception.getCause() );
-            }
-            else if ( isNoteworthyException( exception ) )
-            {
-                reference = exception.getClass().getSimpleName();
-            }
-        }
-
-        if ( StringUtils.isNotEmpty( reference ) && !reference.startsWith( "http:" ) )
-        {
-            reference = "http://cwiki.apache.org/confluence/display/MAVEN/" + reference;
-        }
-
-        return reference;
-    }
-
-    private boolean isNoteworthyException( Throwable exception )
-    {
-        if ( exception == null )
-        {
-            return false;
-        }
-        else if ( exception instanceof Error )
-        {
-            return true;
-        }
-        else if ( exception instanceof RuntimeException )
-        {
-            return false;
-        }
-        else if ( exception.getClass().getName().startsWith( "java" ) )
-        {
-            return false;
-        }
-        return true;
-    }
-
     private String getMessage( String message, Throwable exception )
     {
         String fullMessage = ( message != null ) ? message : "";
diff --git a/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java b/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java
index 9727bdf..82a0c79 100644
--- a/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java
@@ -24,14 +24,14 @@ import java.net.ConnectException;
 
 import org.apache.maven.plugin.MojoExecutionException;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * @author <a href="mailto:baerrach@apache.org">Barrie Treloar</a>
  */
-public class DefaultExceptionHandlerTest
-    extends TestCase
-{
+public class DefaultExceptionHandlerTest {
     /**
      * Running Maven under JDK7 may cause connection issues because IPv6 is used by default.
      * <p>
@@ -42,19 +42,19 @@ public class DefaultExceptionHandlerTest
      * http://cwiki.apache.org/confluence/display/MAVEN/ConnectException
      * </p>
      */
+    @Test
     public void testJdk7ipv6()
     {
         ConnectException connEx = new ConnectException( "Connection refused: connect" );
-        IOException ioEx = new IOException( "Unable to establish loopback connection" );
-        ioEx.initCause( connEx );
+        IOException ioEx = new IOException( "Unable to establish loopback connection", connEx );
         MojoExecutionException mojoEx =
             new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx );
 
         ExceptionHandler exceptionHandler = new DefaultExceptionHandler();
         ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx );
 
-        String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException";
-        assertEquals( expectedReference, exceptionSummary.getReference() );
+        assertEquals( "", exceptionSummary.getReference() );
+        assertEquals( mojoEx, exceptionSummary.getException() );
 
     }
 }
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 6a1a34a..11f684e 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
@@ -992,18 +992,6 @@ public class MavenCli
                     + " switch to enable full debug logging." );
             }
 
-            if ( !references.isEmpty() )
-            {
-                slf4jLogger.error( "" );
-                slf4jLogger.error( "For more information about the errors and possible solutions"
-                                       + ", please read the following articles:" );
-
-                for ( Map.Entry<String, String> entry : references.entrySet() )
-                {
-                    slf4jLogger.error( buffer().strong( entry.getValue() ) + " " + entry.getKey() );
-                }
-            }
-
             if ( project != null && !project.equals( result.getTopologicallySortedProjects().get( 0 ) ) )
             {
                 slf4jLogger.error( "" );