mirror of https://github.com/apache/maven.git
o starting the simplification of the error reporting
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@769193 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a0c50f8554
commit
e10d95d4e1
|
@ -31,6 +31,7 @@ import org.apache.maven.execution.MavenSession;
|
|||
import org.apache.maven.execution.RuntimeInformation;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
|
@ -103,7 +104,7 @@ public class DefaultMaven
|
|||
|
||||
return result;
|
||||
}
|
||||
catch ( BuildFailureException e )
|
||||
catch ( MojoFailureException e )
|
||||
{
|
||||
result.addException( e );
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface MavenExecutionResult
|
|||
// - project building exception
|
||||
// - invalid project model exception: list of markers
|
||||
// - xmlpull parser exception
|
||||
List getExceptions();
|
||||
List<Exception> getExceptions();
|
||||
|
||||
MavenExecutionResult addException( Throwable e );
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.maven.BuildFailureException;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
|
||||
|
@ -73,7 +72,7 @@ public class DefaultLifecycleExecutor
|
|||
private Map<String, Lifecycle> phaseToLifecycleMap;
|
||||
|
||||
public void execute( MavenSession session )
|
||||
throws BuildFailureException, LifecycleExecutionException
|
||||
throws LifecycleExecutionException, MojoFailureException
|
||||
{
|
||||
// TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built
|
||||
// within the same reactor (using an inclusion pattern to gather them up)...
|
||||
|
@ -93,7 +92,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
if ( goals.isEmpty() )
|
||||
{
|
||||
throw new BuildFailureException( "\n\nYou must specify at least one goal. Try 'mvn install' to build or 'mvn --help' for options \nSee http://maven.apache.org for more information.\n\n" );
|
||||
throw new LifecycleExecutionException( "\n\nYou must specify at least one goal. Try 'mvn install' to build or 'mvn --help' for options \nSee http://maven.apache.org for more information.\n\n" );
|
||||
}
|
||||
|
||||
for ( MavenProject currentProject : session.getSortedProjects() )
|
||||
|
@ -126,7 +125,7 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
private void executeGoalAndHandleFailures( String task, MavenSession session, MavenProject project, long buildStartTime, String target )
|
||||
throws BuildFailureException, LifecycleExecutionException
|
||||
throws LifecycleExecutionException, MojoFailureException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -139,13 +138,6 @@ public class DefaultLifecycleExecutor
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
catch ( BuildFailureException e )
|
||||
{
|
||||
if ( handleExecutionFailure( session, project, e, task, buildStartTime ) )
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleExecutionFailure( MavenSession session, MavenProject project, Exception e, String task, long buildStartTime )
|
||||
|
@ -168,7 +160,7 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
private void executeGoal( String task, MavenSession session, MavenProject project )
|
||||
throws LifecycleExecutionException, BuildFailureException
|
||||
throws LifecycleExecutionException, MojoFailureException
|
||||
{
|
||||
List<MojoDescriptor> lifecyclePlan = calculateLifecyclePlan( task, session );
|
||||
|
||||
|
@ -182,11 +174,6 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
pluginManager.executeMojo( session, mojoExecution );
|
||||
}
|
||||
catch ( MojoFailureException e )
|
||||
{
|
||||
// If the mojo actually screws up, like a compilation error
|
||||
throw new LifecycleExecutionException( "Error executing goal.", e );
|
||||
}
|
||||
catch ( PluginExecutionException e )
|
||||
{
|
||||
// This looks like a duplicate
|
||||
|
@ -308,9 +295,9 @@ public class DefaultLifecycleExecutor
|
|||
MojoDescriptor md = getMojoDescriptor( s, session, project );
|
||||
|
||||
boolean include = lifecycle.getPhases().contains( md.getPhase() );
|
||||
System.out.println( ">>> " + goal );
|
||||
System.out.println( ">>> " + md.getPhase() );
|
||||
System.out.println( ">>> " + include );
|
||||
// System.out.println( ">>> " + goal );
|
||||
// System.out.println( ">>> " + md.getPhase() );
|
||||
// System.out.println( ">>> " + include );
|
||||
|
||||
// need to know if this plugin belongs to a phase in the lifecycle that's running
|
||||
if ( md.getPhase() != null && include )
|
||||
|
@ -337,11 +324,6 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
}
|
||||
|
||||
for ( MojoDescriptor md : lifecyclePlan )
|
||||
{
|
||||
System.out.println( md.getGoal() );
|
||||
}
|
||||
|
||||
return lifecyclePlan;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.maven.BuildFailureException;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -44,5 +45,5 @@ public interface LifecycleExecutor
|
|||
throws LifecycleExecutionException;
|
||||
|
||||
void execute( MavenSession session )
|
||||
throws LifecycleExecutionException, BuildFailureException;
|
||||
throws LifecycleExecutionException, MojoFailureException;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.maven.cli;
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
|
@ -33,6 +34,7 @@ import org.apache.maven.embedder.MavenEmbedderFileLogger;
|
|||
import org.apache.maven.embedder.MavenEmbedderLogger;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||
|
||||
/**
|
||||
|
@ -165,7 +167,22 @@ public class MavenCli
|
|||
|
||||
MavenExecutionResult result = mavenEmbedder.execute( request );
|
||||
|
||||
CLIReportingUtils.logResult( request, result, logger );
|
||||
//CLIReportingUtils.logResult( request, result, logger );
|
||||
|
||||
System.out.println( "exceptions: " + result.hasExceptions() );
|
||||
|
||||
System.out.println( result.getExceptions() );
|
||||
|
||||
Exception e = result.getExceptions().get( 0 );
|
||||
|
||||
if ( e instanceof MojoFailureException )
|
||||
{
|
||||
System.out.println( ((MojoFailureException)e).getLongMessage() );
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println( e.getMessage() );
|
||||
}
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
|
|
|
@ -22,10 +22,9 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
|
@ -48,14 +47,13 @@ import org.apache.maven.model.interpolator.PomInterpolatorTag;
|
|||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.profiles.DefaultProfileManager;
|
||||
import org.apache.maven.profiles.ProfileActivationException;
|
||||
import org.apache.maven.profiles.ProfileManagerInfo;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.profiles.ProfileManagerInfo;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
import org.apache.maven.project.validation.ModelValidator;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.VersionNotFoundException;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -303,14 +301,16 @@ public class DefaultMavenProjectBuilder
|
|||
public MavenProject buildFromRepository( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if(remoteRepositories == null)
|
||||
if(remoteRepositories == null)
|
||||
{
|
||||
throw new IllegalArgumentException("repositories: null");
|
||||
}
|
||||
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepositories(remoteRepositories);
|
||||
return buildFromRepository(artifact, configuration);
|
||||
|
||||
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepositories(remoteRepositories);
|
||||
|
||||
return buildFromRepository(artifact, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue