o Polished error reporting

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@800482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-03 18:08:55 +00:00
parent 62e07ca349
commit b454fb7cb6
6 changed files with 42 additions and 9 deletions

View File

@ -38,6 +38,7 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ProjectDependencyGraph;
import org.apache.maven.execution.ProjectSorter;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
@ -293,6 +294,27 @@ public class DefaultMaven
for ( ProjectBuildingResult result : results )
{
projects.add( result.getProject() );
if ( !result.getProblems().isEmpty() && logger.isWarnEnabled() )
{
logger.warn( "" );
logger.warn( "Some problems were encountered while building the effective model for "
+ result.getProject().getId() );
logger.warn( "" );
for ( ModelProblem problem : result.getProblems() )
{
logger.warn( problem.getMessage() + " @ " + problem.getSource() );
}
logger.warn( "" );
logger.warn( "It is highly recommended to fix these problems"
+ " because they threaten the stability of your build." );
logger.warn( "" );
logger.warn( "For this reason, future Maven versions will no"
+ " longer support building such malformed projects." );
logger.warn( "" );
}
}
}

View File

@ -1115,7 +1115,7 @@ public class DefaultLifecycleExecutor
}
catch ( PluginNotFoundException e )
{
throw new LifecycleExecutionException( "Error resolving version for plugin " + plugin, e );
throw new LifecycleExecutionException( "Error resolving version for plugin " + plugin.getKey(), e );
}
}

View File

@ -315,8 +315,12 @@ public class ProjectBuildingException
{
for ( ModelProblem problem : result.getProblems() )
{
writer.print( "o " );
writer.println( problem.getMessage() );
writer.print( "[" );
writer.print( problem.getSeverity() );
writer.print( "] " );
writer.print( problem.getMessage() );
writer.print( " @ " );
writer.println( problem.getSource() );
}
}
writer.close();

View File

@ -185,7 +185,10 @@ public class MavenCli
{
System.out.println( es.getMessage() );
es.getException().printStackTrace();
if ( showErrors )
{
es.getException().printStackTrace();
}
}
if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( request.getReactorFailureBehavior() ) )

View File

@ -510,9 +510,9 @@ public class DefaultModelBuilder
catch ( UnresolvableModelException e )
{
problems.add( new ModelProblem( "Non-resolvable parent POM "
+ ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
+ ModelProblemUtils.toSourceHint( childModel ) + ": " + e.getMessage(), ModelProblem.Severity.FATAL,
ModelProblemUtils.toSourceHint( childModel ), e ) );
+ ModelProblemUtils.toId( groupId, artifactId, version ) + ": " + e.getMessage(),
ModelProblem.Severity.FATAL, ModelProblemUtils.toSourceHint( childModel ),
e ) );
throw new ModelBuildingException( problems.getProblems() );
}

View File

@ -75,8 +75,12 @@ public class ModelBuildingException
for ( ModelProblem problem : problems )
{
writer.print( "o " );
writer.println( problem.getMessage() );
writer.print( "[" );
writer.print( problem.getSeverity() );
writer.print( "] " );
writer.print( problem.getMessage() );
writer.print( " @ " );
writer.println( problem.getSource() );
}
return buffer.toString();