mirror of https://github.com/apache/maven.git
[MNG-3194] Fixing logging problems, but error diagnosis is still missing from CLI version of things...this should probably be replaced and/or restored. I'll commit unit tests for 3194 next.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@583314 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ea31f3e3f7
commit
dc6e7c8368
|
@ -35,6 +35,7 @@ import org.apache.maven.execution.RuntimeInformation;
|
|||
import org.apache.maven.execution.SessionContext;
|
||||
import org.apache.maven.extension.BuildExtensionScanner;
|
||||
import org.apache.maven.extension.ExtensionScanningException;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||
import org.apache.maven.lifecycle.TaskValidationResult;
|
||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||
|
@ -47,7 +48,6 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.reactor.MavenExecutionException;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.context.Context;
|
||||
|
@ -221,13 +221,14 @@ public class DefaultMaven
|
|||
reactorManager,
|
||||
dispatcher );
|
||||
}
|
||||
catch ( Exception e )
|
||||
catch ( LifecycleExecutionException e )
|
||||
{
|
||||
result.addException(
|
||||
new BuildFailureException(
|
||||
e.getMessage(),
|
||||
e ) );
|
||||
|
||||
result.addException( e );
|
||||
return result;
|
||||
}
|
||||
catch ( BuildFailureException e )
|
||||
{
|
||||
result.addException( e );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -334,7 +335,7 @@ public class DefaultMaven
|
|||
project.setExecutionRoot( true );
|
||||
}
|
||||
|
||||
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
|
||||
if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) )
|
||||
{
|
||||
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
|
||||
|
||||
|
@ -346,7 +347,7 @@ public class DefaultMaven
|
|||
}
|
||||
}
|
||||
|
||||
if ( project.getModules() != null && !project.getModules().isEmpty() && recursive )
|
||||
if ( ( project.getModules() != null ) && !project.getModules().isEmpty() && recursive )
|
||||
{
|
||||
// TODO: Really should fail if it was not? What if it is aggregating - eg "ear"?
|
||||
project.setPackaging( "pom" );
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.cli;
|
|||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.maven.BuildFailureException;
|
||||
import org.apache.maven.MavenTransferListener;
|
||||
import org.apache.maven.embedder.Configuration;
|
||||
import org.apache.maven.embedder.ConfigurationValidationResult;
|
||||
|
@ -35,6 +36,7 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.plugin.AbstractMojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||
|
||||
|
@ -544,7 +546,7 @@ public class MavenCli
|
|||
|
||||
logReactorSummary( reactorManager );
|
||||
|
||||
if ( reactorManager != null && reactorManager.hasBuildFailures() )
|
||||
if ( ( reactorManager != null ) && reactorManager.hasBuildFailures() )
|
||||
{
|
||||
logErrors(
|
||||
reactorManager,
|
||||
|
@ -572,7 +574,14 @@ public class MavenCli
|
|||
{
|
||||
Exception e = (Exception) i.next();
|
||||
|
||||
showError( e.getMessage(), e, request.isShowErrors() );
|
||||
if ( e instanceof BuildFailureException )
|
||||
{
|
||||
showFailure( e, request.isShowErrors() );
|
||||
}
|
||||
else
|
||||
{
|
||||
showError( e.getMessage(), e, request.isShowErrors() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -617,6 +626,40 @@ public class MavenCli
|
|||
}
|
||||
}
|
||||
|
||||
private static void showFailure( Exception e,
|
||||
boolean show )
|
||||
{
|
||||
String message = e.getMessage();
|
||||
Throwable cause = e.getCause();
|
||||
if ( ( cause != null ) && ( cause instanceof AbstractMojoExecutionException ) )
|
||||
{
|
||||
message = ((AbstractMojoExecutionException)cause).getLongMessage();
|
||||
if ( message == null )
|
||||
{
|
||||
message = cause.getMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cause = e;
|
||||
}
|
||||
|
||||
System.err.println();
|
||||
System.err.println( message );
|
||||
System.err.println();
|
||||
|
||||
if ( show )
|
||||
{
|
||||
System.err.println( "Error stacktrace:" );
|
||||
|
||||
cause.printStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println( "For more information, run with the -e flag" );
|
||||
}
|
||||
}
|
||||
|
||||
private static void showError( String message,
|
||||
Exception e,
|
||||
boolean show )
|
||||
|
@ -639,7 +682,7 @@ public class MavenCli
|
|||
|
||||
private void logReactorSummary( ReactorManager rm )
|
||||
{
|
||||
if ( rm != null && rm.hasMultipleProjects() && rm.executedMultipleProjects() )
|
||||
if ( ( rm != null ) && rm.hasMultipleProjects() && rm.executedMultipleProjects() )
|
||||
{
|
||||
getLogger().info( "" );
|
||||
getLogger().info( "" );
|
||||
|
|
Loading…
Reference in New Issue