diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java
index 90356d0a81..55c6add2b8 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java
@@ -80,28 +80,26 @@ public class ArtifactResolutionException
}
}
- // TODO: don't show this section for metadata
- sb.append( LS );
- sb.append( LS );
- sb.append( "Try downloading the file manually" );
- if ( downloadUrl != null )
+ if ( downloadUrl != null && !type.equals( "pom" ) )
{
- sb.append( " from " );
+ sb.append( LS );
+ sb.append( LS );
+ sb.append( "Try downloading the file manually from" );
sb.append( LS );
sb.append( " " + downloadUrl );
+ sb.append( LS );
+ sb.append( "and install it using the command: " );
+ sb.append( LS );
+ sb.append( " m2 install:install-file -DgroupId=" );
+ sb.append( groupId );
+ sb.append( " -DartifactId=" );
+ sb.append( artifactId );
+ sb.append( " -Dversion=" );
+ sb.append( version );
+ sb.append( " -Dpackaging=" );
+ sb.append( type );
+ sb.append( " -Dfile=/path/to/file" );
}
- sb.append( LS );
- sb.append( "and install it using the command: " );
- sb.append( LS );
- sb.append( " m2 install:install-file -DgroupId=" );
- sb.append( groupId );
- sb.append( " -DartifactId=" );
- sb.append( artifactId );
- sb.append( " -Dversion=" );
- sb.append( version );
- sb.append( " -Dpackaging=" );
- sb.append( type );
- sb.append( " -Dfile=/path/to/file" );
return sb.toString();
}
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 73a67d84bf..e470195383 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -58,6 +58,7 @@ import java.util.Map;
/**
* @author Jason van Zyl
* @version $Id$
+ * @todo unify error reporting. We should return one response, always - and let the CLI decide how to render it. The reactor response should contain individual project responses
*/
public class DefaultMaven
extends AbstractLogEnabled
@@ -120,17 +121,33 @@ public class DefaultMaven
{
throw new ReactorException( "Error processing projects for the reactor: ", e );
}
- catch ( ProjectBuildingException e )
- {
- throw new ReactorException( "Error processing projects for the reactor: ", e );
- }
catch ( CycleDetectedException e )
{
throw new ReactorException( "Error processing projects for the reactor: ", e );
}
catch ( ArtifactResolutionException e )
{
- throw new ReactorException( "Error processing projects for the reactor: ", e );
+ dispatcher.dispatchError( event, request.getBaseDirectory(), e );
+
+ MavenExecutionResponse response = new MavenExecutionResponse();
+ response.setStart( new Date() );
+ response.setFinish( new Date() );
+ response.setException( e );
+ logFailure( response, e, null );
+
+ return response;
+ }
+ catch ( ProjectBuildingException e )
+ {
+ dispatcher.dispatchError( event, request.getBaseDirectory(), e );
+
+ MavenExecutionResponse response = new MavenExecutionResponse();
+ response.setStart( new Date() );
+ response.setFinish( new Date() );
+ response.setException( e );
+ logFailure( response, e, null );
+
+ return response;
}
try
@@ -150,6 +167,8 @@ public class DefaultMaven
MavenExecutionResponse response = processProject( request, project, dispatcher );
if ( response.isExecutionFailure() )
{
+ dispatcher.dispatchError( event, request.getBaseDirectory(), response.getException() );
+
return response;
}
}
@@ -414,6 +433,7 @@ public class DefaultMaven
line();
}
+ // TODO: needs to honour -e
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Trace", e );
diff --git a/maven-core/src/main/java/org/apache/maven/Maven.java b/maven-core/src/main/java/org/apache/maven/Maven.java
index 298d7391c1..6b32f3b18b 100644
--- a/maven-core/src/main/java/org/apache/maven/Maven.java
+++ b/maven-core/src/main/java/org/apache/maven/Maven.java
@@ -19,6 +19,8 @@ package org.apache.maven;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResponse;
import org.apache.maven.reactor.ReactorException;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
/**
* @author Jason van Zyl
diff --git a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
index e3d29ec4f2..320f7cd4d0 100644
--- a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -272,7 +272,7 @@ public class MavenCli
}
else
{
- System.err.println( "For more information, run with the -X flag" );
+ System.err.println( "For more information, run with the -e flag" );
}
}