mirror of https://github.com/apache/maven.git
Adding more error-reporting fixes and unit tests.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@611945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c4ba075688
commit
c3983894ab
|
@ -3,6 +3,9 @@ package org.apache.maven.errors;
|
|||
public abstract aspect AbstractCoreReporterAspect
|
||||
{
|
||||
|
||||
protected pointcut notWithinAspect():
|
||||
!within( *.*Aspect+ );
|
||||
|
||||
protected CoreErrorReporter getReporter()
|
||||
{
|
||||
return CoreReporterManager.getReporter();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.apache.maven.errors;
|
||||
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.lifecycle.TaskValidationResult;
|
||||
import org.apache.maven.lifecycle.LifecycleLoaderException;
|
||||
import org.apache.maven.lifecycle.LifecycleSpecificationException;
|
||||
import org.apache.maven.plugin.loader.PluginLoaderException;
|
||||
|
@ -9,17 +8,24 @@ import org.apache.maven.ProjectCycleException;
|
|||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.lifecycle.model.MojoBinding;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||
import org.apache.maven.lifecycle.DefaultLifecycleExecutor;
|
||||
import org.apache.maven.NoGoalsSpecifiedException;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.AggregatedBuildFailureException;
|
||||
import org.apache.maven.ProjectBuildFailureException;
|
||||
import org.apache.maven.Maven;
|
||||
import org.apache.maven.plugin.loader.PluginLoader;
|
||||
import org.apache.maven.lifecycle.binding.MojoBindingFactory;
|
||||
|
||||
public aspect BuildFailureReporterAspect
|
||||
public privileged aspect BuildFailureReporterAspect
|
||||
extends AbstractCoreReporterAspect
|
||||
{
|
||||
|
||||
private pointcut within_le_execute( MavenSession session, ReactorManager reactorManager ):
|
||||
withincode( void LifecycleExecutor+.execute( MavenSession, ReactorManager, .. ) )
|
||||
&& args( session, reactorManager, .. );
|
||||
|
||||
private pointcut le_execute( MavenSession session, ReactorManager reactorManager ):
|
||||
execution( void LifecycleExecutor+.execute( MavenSession, ReactorManager, .. ) )
|
||||
&& args( session, reactorManager, .. );
|
||||
|
@ -35,12 +41,15 @@ public aspect BuildFailureReporterAspect
|
|||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
after( ReactorManager reactorManager, NoGoalsSpecifiedException err ):
|
||||
NoGoalsSpecifiedException around( ReactorManager reactorManager ):
|
||||
cflow( le_execute( MavenSession, reactorManager ) )
|
||||
&& execution( NoGoalsSpecifiedException.new( .. ) )
|
||||
&& this( err )
|
||||
&& call( NoGoalsSpecifiedException.new( .. ) )
|
||||
{
|
||||
NoGoalsSpecifiedException err = proceed( reactorManager );
|
||||
|
||||
getReporter().reportNoGoalsSpecifiedException( reactorManager.getTopLevelProject(), err );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
private pointcut aggregatedBuildFailureException_ctor( MojoBinding binding, MojoFailureException cause ):
|
||||
|
@ -113,9 +122,8 @@ public aspect BuildFailureReporterAspect
|
|||
getReporter().reportProjectCycle( err );
|
||||
}
|
||||
|
||||
private pointcut le_isTaskValid( MavenSession session, MavenProject rootProject ):
|
||||
execution( TaskValidationResult LifecycleExecutor+.isTaskValid( .., MavenSession, MavenProject ) )
|
||||
&& args( .., session, rootProject );
|
||||
private pointcut within_le_getMojoDescriptorForDirectInvocation():
|
||||
withincode( * DefaultLifecycleExecutor.getMojoDescriptorForDirectInvocation( String, MavenSession, MavenProject ) );
|
||||
|
||||
/**
|
||||
* Call stack is:
|
||||
|
@ -129,15 +137,20 @@ public aspect BuildFailureReporterAspect
|
|||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
before( MavenSession session, MavenProject rootProject, PluginLoaderException cause, TaskValidationResult result ):
|
||||
cflow( le_isTaskValid( session, rootProject ) )
|
||||
&& execution( TaskValidationResult.new( .., PluginLoaderException ) )
|
||||
&& args( .., cause )
|
||||
&& this( result )
|
||||
after( MojoBinding binding, MavenSession session, MavenProject rootProject ) throwing ( PluginLoaderException cause ):
|
||||
within_le_getMojoDescriptorForDirectInvocation()
|
||||
&& call( * PluginLoader+.loadPlugin( MojoBinding, MavenProject, MavenSession ) )
|
||||
&& args( binding, rootProject, session )
|
||||
{
|
||||
getReporter().reportPluginErrorWhileValidatingTask( session, rootProject, cause, result );
|
||||
getReporter().reportPluginErrorWhileValidatingTask( binding.getGoal(), session, rootProject, cause );
|
||||
}
|
||||
|
||||
// before():
|
||||
// call( * MojoBindingFactory+.parseMojoBinding( String, MavenProject, MavenSession, boolean ) )
|
||||
// {
|
||||
// System.out.println( "Boo" );
|
||||
// }
|
||||
|
||||
/**
|
||||
* Call stack is:
|
||||
* <br/>
|
||||
|
@ -150,13 +163,12 @@ public aspect BuildFailureReporterAspect
|
|||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
before( MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause, TaskValidationResult result ):
|
||||
cflow( le_isTaskValid( session, rootProject ) )
|
||||
&& execution( TaskValidationResult.new( .., LifecycleSpecificationException ) )
|
||||
&& args( .., cause )
|
||||
&& this( result )
|
||||
after( String task, MavenSession session, MavenProject rootProject ) throwing ( LifecycleSpecificationException cause ):
|
||||
within_le_getMojoDescriptorForDirectInvocation()
|
||||
&& call( * MojoBindingFactory+.parseMojoBinding( String, MavenProject, MavenSession, .. ) )
|
||||
&& args( task, rootProject, session, .. )
|
||||
{
|
||||
getReporter().reportLifecycleSpecErrorWhileValidatingTask( session, rootProject, cause, result );
|
||||
getReporter().reportLifecycleSpecErrorWhileValidatingTask( task, session, rootProject, cause );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,13 +183,12 @@ public aspect BuildFailureReporterAspect
|
|||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
before( MavenSession session, MavenProject rootProject, LifecycleLoaderException cause, TaskValidationResult result ):
|
||||
cflow( le_isTaskValid( session, rootProject ) )
|
||||
&& execution( TaskValidationResult.new( .., LifecycleLoaderException ) )
|
||||
&& args( .., cause )
|
||||
&& this( result )
|
||||
after( String task, MavenSession session, MavenProject rootProject ) throwing ( LifecycleLoaderException cause ):
|
||||
within_le_getMojoDescriptorForDirectInvocation()
|
||||
&& call( * MojoBindingFactory+.parseMojoBinding( String, MavenProject, MavenSession, .. ) )
|
||||
&& args( task, rootProject, session, .. )
|
||||
{
|
||||
getReporter().reportLifecycleLoaderErrorWhileValidatingTask( session, rootProject, cause, result );
|
||||
getReporter().reportLifecycleLoaderErrorWhileValidatingTask( task, session, rootProject, cause );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.maven.plugin.version.DefaultPluginVersionManager;
|
|||
import org.apache.maven.execution.RuntimeInformation;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -47,17 +46,6 @@ public privileged aspect ExtensionErrorReporterAspect
|
|||
getReporter().handleSuperPomBuildingError( cause );
|
||||
}
|
||||
|
||||
private pointcut within_dbes_checkModulesForExtensions():
|
||||
withincode( * DefaultBuildExtensionScanner.checkModulesForExtensions( File, Model, MavenExecutionRequest, List, List, List ) );
|
||||
|
||||
before( File pomFile, IOException cause ):
|
||||
within_dbes_checkModulesForExtensions()
|
||||
&& call( ExtensionScanningException.new( String, File, String, IOException ) )
|
||||
&& args( *, pomFile, *, cause )
|
||||
{
|
||||
getReporter().reportPomFileCanonicalizationError( pomFile, cause );
|
||||
}
|
||||
|
||||
private pointcut dbes_scanInternal( File pomFile, MavenExecutionRequest request ):
|
||||
execution( void DefaultBuildExtensionScanner.scanInternal( File, MavenExecutionRequest, .. ) )
|
||||
&& args( pomFile, request, .. );
|
||||
|
@ -123,7 +111,7 @@ public privileged aspect ExtensionErrorReporterAspect
|
|||
&& within_dem_addPluginAsExtension()
|
||||
&& call_eme_ctor_RealmManagementException( cause )
|
||||
{
|
||||
getReporter().reportErrorManagingRealmForExtensionPlugin( plugin, originModel, remoteRepos, request, cause );
|
||||
getReporter().reportErrorConfiguringExtensionPluginRealm( plugin, originModel, remoteRepos, request, cause );
|
||||
}
|
||||
|
||||
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause ):
|
||||
|
|
|
@ -10,10 +10,8 @@ import org.apache.maven.DefaultMaven;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public aspect MavenExecErrorReporterAspect
|
||||
|
@ -49,13 +47,16 @@ public aspect MavenExecErrorReporterAspect
|
|||
return currentProject;
|
||||
}
|
||||
|
||||
before( MavenExecutionException err ):
|
||||
MavenExecutionException around():
|
||||
cflow( dm_getProjects( MavenExecutionRequest ) )
|
||||
&& cflow( dm_collectProjects( ArtifactRepository, ProfileManager ) )
|
||||
&& execution( MavenExecutionException.new( String, File ) )
|
||||
&& this( err )
|
||||
&& call( MavenExecutionException.new( String, File ) )
|
||||
{
|
||||
MavenExecutionException err = proceed();
|
||||
|
||||
getReporter().reportInvalidMavenVersion( currentProject, mavenVersion, err );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
after(): dm_collectProjects( ArtifactRepository, ProfileManager )
|
||||
|
@ -63,22 +64,4 @@ public aspect MavenExecErrorReporterAspect
|
|||
currentProject = null;
|
||||
}
|
||||
|
||||
after( File basedir, String includes, String excludes ) throwing( IOException cause ):
|
||||
cflow( dm_getProjects( MavenExecutionRequest ) )
|
||||
&& cflow( execution( * DefaultMaven.getProjectFiles( MavenExecutionRequest ) ) )
|
||||
&& call( * FileUtils.getFiles( File, String, String ) )
|
||||
&& args( basedir, includes, excludes )
|
||||
{
|
||||
getReporter().reportPomFileScanningError( basedir, includes, excludes, cause );
|
||||
}
|
||||
|
||||
after( File pomFile ) throwing( IOException cause ):
|
||||
cflow( dm_getProjects( MavenExecutionRequest ) )
|
||||
&& cflow( dm_collectProjects( ArtifactRepository, ProfileManager ) )
|
||||
&& call( File File.getCanonicalFile() )
|
||||
&& target( pomFile )
|
||||
{
|
||||
getReporter().reportPomFileCanonicalizationError( pomFile, cause );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.apache.maven.lifecycle.LifecycleException;
|
|||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
import org.apache.maven.lifecycle.LifecycleLoaderException;
|
||||
import org.apache.maven.lifecycle.LifecycleSpecificationException;
|
||||
import org.apache.maven.lifecycle.TaskValidationResult;
|
||||
import org.apache.maven.lifecycle.model.MojoBinding;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
@ -46,7 +45,6 @@ import org.codehaus.plexus.configuration.PlexusConfiguration;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -64,6 +62,8 @@ public interface CoreErrorReporter
|
|||
|
||||
void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause );
|
||||
|
||||
void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
|
||||
|
||||
void reportErrorFormulatingBuildPlan( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause );
|
||||
|
||||
void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause );
|
||||
|
@ -72,8 +72,6 @@ public interface CoreErrorReporter
|
|||
|
||||
void reportErrorManagingRealmForExtension( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
|
||||
|
||||
void reportErrorManagingRealmForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
|
||||
|
||||
void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err );
|
||||
|
||||
void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause );
|
||||
|
@ -92,9 +90,9 @@ public interface CoreErrorReporter
|
|||
|
||||
void reportInvalidPluginExecutionEnvironment( MojoBinding binding, MavenProject project, PluginExecutionException cause );
|
||||
|
||||
void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleLoaderException cause, TaskValidationResult result );
|
||||
void reportLifecycleLoaderErrorWhileValidatingTask( String task, MavenSession session, MavenProject rootProject, LifecycleLoaderException cause );
|
||||
|
||||
void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause, TaskValidationResult result );
|
||||
void reportLifecycleSpecErrorWhileValidatingTask( String task, MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause );
|
||||
|
||||
void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause );
|
||||
|
||||
|
@ -108,11 +106,7 @@ public interface CoreErrorReporter
|
|||
|
||||
void reportNoGoalsSpecifiedException( MavenProject rootProject, NoGoalsSpecifiedException error );
|
||||
|
||||
void reportPluginErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, PluginLoaderException cause, TaskValidationResult result );
|
||||
|
||||
void reportPomFileCanonicalizationError( File pomFile, IOException cause );
|
||||
|
||||
void reportPomFileScanningError( File basedir, String includes, String excludes, IOException cause );
|
||||
void reportPluginErrorWhileValidatingTask( String task, MavenSession session, MavenProject rootProject, PluginLoaderException cause );
|
||||
|
||||
void reportProjectCycle( ProjectCycleException error );
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.apache.maven.artifact.versioning.ArtifactVersion;
|
|||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.execution.RealmManagementException;
|
||||
import org.apache.maven.lifecycle.LifecycleException;
|
||||
import org.apache.maven.lifecycle.TaskValidationResult;
|
||||
import org.apache.maven.lifecycle.model.MojoBinding;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
@ -67,7 +66,7 @@ public final class CoreErrorTips
|
|||
return null;
|
||||
}
|
||||
|
||||
public static List getTaskValidationTips( TaskValidationResult result, Exception cause )
|
||||
public static List getTaskValidationTips( String task, Exception cause )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.apache.maven.lifecycle.LifecycleExecutionException;
|
|||
import org.apache.maven.lifecycle.LifecycleLoaderException;
|
||||
import org.apache.maven.lifecycle.LifecycleSpecificationException;
|
||||
import org.apache.maven.lifecycle.MojoBindingUtils;
|
||||
import org.apache.maven.lifecycle.TaskValidationResult;
|
||||
import org.apache.maven.lifecycle.model.MojoBinding;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
|
@ -56,7 +55,6 @@ import org.codehaus.plexus.logging.Logger;
|
|||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -251,58 +249,58 @@ public class DefaultCoreErrorReporter
|
|||
registerBuildError( error, writer.toString(), cause );
|
||||
}
|
||||
|
||||
public void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session,
|
||||
public void reportLifecycleLoaderErrorWhileValidatingTask( String task,
|
||||
MavenSession session,
|
||||
MavenProject rootProject,
|
||||
LifecycleLoaderException cause,
|
||||
TaskValidationResult result )
|
||||
LifecycleLoaderException cause )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Invalid mojo or lifecycle phase: " );
|
||||
writer.write( result.getInvalidTask() );
|
||||
writer.write( task );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
|
||||
writer.write( "Original error message was: " );
|
||||
writer.write( cause.getMessage() );
|
||||
|
||||
addTips( CoreErrorTips.getTaskValidationTips( result, cause ), writer );
|
||||
addTips( CoreErrorTips.getTaskValidationTips( task, cause ), writer );
|
||||
|
||||
registerBuildError( cause, writer.toString(), cause.getCause() );
|
||||
}
|
||||
|
||||
public void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session,
|
||||
public void reportLifecycleSpecErrorWhileValidatingTask( String task,
|
||||
MavenSession session,
|
||||
MavenProject rootProject,
|
||||
LifecycleSpecificationException cause,
|
||||
TaskValidationResult result )
|
||||
LifecycleSpecificationException cause )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Invalid mojo or lifecycle phase: " );
|
||||
writer.write( result.getInvalidTask() );
|
||||
writer.write( task );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
|
||||
writer.write( "Original error message was: " );
|
||||
writer.write( cause.getMessage() );
|
||||
|
||||
addTips( CoreErrorTips.getTaskValidationTips( result, cause ), writer );
|
||||
addTips( CoreErrorTips.getTaskValidationTips( task, cause ), writer );
|
||||
|
||||
registerBuildError( cause, writer.toString(), cause.getCause() );
|
||||
}
|
||||
|
||||
public void reportPluginErrorWhileValidatingTask( MavenSession session,
|
||||
public void reportPluginErrorWhileValidatingTask( String task,
|
||||
MavenSession session,
|
||||
MavenProject rootProject,
|
||||
PluginLoaderException cause,
|
||||
TaskValidationResult result )
|
||||
PluginLoaderException cause )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Invalid mojo or lifecycle phase: " );
|
||||
writer.write( result.getInvalidTask() );
|
||||
writer.write( task );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
|
||||
|
@ -314,7 +312,7 @@ public class DefaultCoreErrorReporter
|
|||
writer.write( "Original error message was: " );
|
||||
writer.write( cause.getMessage() );
|
||||
|
||||
addTips( CoreErrorTips.getTaskValidationTips( result, cause ), writer );
|
||||
addTips( CoreErrorTips.getTaskValidationTips( task, cause ), writer );
|
||||
|
||||
registerBuildError( cause, writer.toString(), cause.getCause() );
|
||||
}
|
||||
|
@ -895,56 +893,6 @@ public class DefaultCoreErrorReporter
|
|||
registerBuildError( err, writer.toString() );
|
||||
}
|
||||
|
||||
public void reportPomFileScanningError( File basedir,
|
||||
String includes,
|
||||
String excludes,
|
||||
IOException cause )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Maven encountered an error while scanning for POM files to build." );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
|
||||
writer.write( "In base directory: " );
|
||||
writer.write( String.valueOf( basedir ) );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "with include pattern(s):" );
|
||||
writer.write( includes );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "and exclude pattern(s):" );
|
||||
writer.write( excludes );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Error message: " );
|
||||
writer.write( cause.getMessage() );
|
||||
|
||||
addTips( CoreErrorTips.getPomFileScanningErrorTips( basedir, includes, excludes ), writer );
|
||||
|
||||
registerBuildError( cause, writer.toString(), cause.getCause() );
|
||||
}
|
||||
|
||||
public void reportPomFileCanonicalizationError( File pomFile,
|
||||
IOException cause )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Maven encountered an error while standardizing your POM's File instance." );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
|
||||
writer.write( "POM file: " );
|
||||
writer.write( String.valueOf( pomFile ) );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( NEWLINE );
|
||||
writer.write( "Error message: " );
|
||||
writer.write( cause.getMessage() );
|
||||
|
||||
registerBuildError( cause, writer.toString(), cause.getCause() );
|
||||
}
|
||||
|
||||
public void handleSuperPomBuildingError( ProjectBuildingException exception )
|
||||
{
|
||||
ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter();
|
||||
|
@ -1197,7 +1145,7 @@ public class DefaultCoreErrorReporter
|
|||
registerBuildError( cause, writer.toString(), cause.getCause() );
|
||||
}
|
||||
|
||||
public void reportErrorManagingRealmForExtensionPlugin( Plugin plugin,
|
||||
public void reportErrorConfiguringExtensionPluginRealm( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
|
|
|
@ -739,9 +739,9 @@ public class DefaultLifecycleExecutor
|
|||
return segments;
|
||||
}
|
||||
|
||||
private MojoDescriptor getMojoDescriptorForDirectInvocation( final String task,
|
||||
final MavenSession session,
|
||||
final MavenProject project )
|
||||
private MojoDescriptor getMojoDescriptorForDirectInvocation( String task,
|
||||
MavenSession session,
|
||||
MavenProject project )
|
||||
throws LifecycleSpecificationException, PluginLoaderException, LifecycleLoaderException
|
||||
{
|
||||
// we don't need to include report configuration here, since we're just looking for
|
||||
|
@ -756,6 +756,7 @@ public class DefaultLifecycleExecutor
|
|||
binding,
|
||||
project,
|
||||
session );
|
||||
|
||||
MojoDescriptor mojoDescriptor = descriptor.getMojo( binding.getGoal() );
|
||||
|
||||
return mojoDescriptor;
|
||||
|
|
|
@ -262,7 +262,7 @@ under the License.
|
|||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
|
||||
<role-hint>default</role-hint>
|
||||
<role-hint>maven-strict</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
|
|
|
@ -339,18 +339,24 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
|
||||
if ( request.getLocalRepository() == null )
|
||||
{
|
||||
request.setLocalRepository( createLocalRepository( request.getSettings(), configuration ) );
|
||||
request.setLocalRepository( createLocalRepository( request, request.getSettings(), configuration ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ArtifactRepository createLocalRepository( Settings settings,
|
||||
public ArtifactRepository createLocalRepository( MavenExecutionRequest request,
|
||||
Settings settings,
|
||||
Configuration configuration )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
String localRepositoryPath = null;
|
||||
|
||||
if ( configuration.getLocalRepository() != null )
|
||||
if ( request.getLocalRepositoryPath() != null )
|
||||
{
|
||||
localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) && ( configuration.getLocalRepository() != null ) )
|
||||
{
|
||||
localRepositoryPath = configuration.getLocalRepository().getAbsolutePath();
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ under the License.
|
|||
<version>1</version>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>[3.1,</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
package org.plugin;
|
||||
|
||||
public class ComponentOne
|
||||
{
|
||||
|
||||
private ComponentTwo two;
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.plugin;
|
||||
|
||||
public class ComponentTwo
|
||||
{
|
||||
|
||||
private ComponentOne one;
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.plugin;
|
||||
|
||||
import org.apache.maven.plugin.Mojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
|
||||
/**
|
||||
* @goal test
|
||||
*
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class TestPlugin
|
||||
implements Mojo
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private ComponentOne one;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
}
|
||||
|
||||
public Log getLog()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
public void setLog( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.test.ComponentOne</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.test.ComponentOne</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.test.ComponentTwo</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.test.ComponentTwo</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.test.ComponentTwo</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.test.ComponentOne</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -0,0 +1,36 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>testReportErrorConfiguringExtensionPluginRealm</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext-plugin</artifactId>
|
||||
<version>1</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>testReportErrorFormulatingBuildPlan-maven-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,35 @@
|
|||
package org.plugin;
|
||||
|
||||
import org.apache.maven.plugin.Mojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
|
||||
/**
|
||||
* @goal test
|
||||
* @execute goal="my:something:else:that:is:wrong"
|
||||
*
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class TestPlugin
|
||||
implements Mojo
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
}
|
||||
|
||||
public Log getLog()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
public void setLog( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>testReportErrorFormulatingBuildPlan</artifactId>
|
||||
<version>1</version>
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext</artifactId>
|
||||
<version>1</version>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package org.ext;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
this is an error.
|
|
@ -0,0 +1,35 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>testReportErrorManagingRealmForExtension</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext</artifactId>
|
||||
<version>1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext-dep</artifactId>
|
||||
<version>1</ver>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext-dep</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,35 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>testReportErrorResolvingExtensionDependencies</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext</artifactId>
|
||||
<version>1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>[3.8,</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,35 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>testReportErrorResolvingExtensionDirectDependencies</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>test-maven-ext</artifactId>
|
||||
<version>1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.errortest</groupId>
|
||||
<artifactId>testReportInvalidMavenVersion</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<prerequisites>
|
||||
<maven>10</maven>
|
||||
</prerequisites>
|
||||
|
||||
</project>
|
|
@ -14,6 +14,8 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.plugin.PluginManagerException;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
@ -22,6 +24,7 @@ import org.easymock.MockControl;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
@ -34,6 +37,8 @@ public class ErrorReporterPointcutTest
|
|||
extends TestCase
|
||||
{
|
||||
|
||||
private static final int ONE_SECOND = 1000;
|
||||
|
||||
private MockControl reporterCtl;
|
||||
|
||||
private CoreErrorReporter reporter;
|
||||
|
@ -81,29 +86,39 @@ public class ErrorReporterPointcutTest
|
|||
"http://repo1.maven.org/maven2/org/apache/maven/maven-core/2.0/maven-core-2.0.pom" );
|
||||
|
||||
HttpConnectionManager mgr = client.getHttpConnectionManager();
|
||||
mgr.getParams().setConnectionTimeout( 1 );
|
||||
mgr.getParams().setConnectionTimeout( 3 * ONE_SECOND );
|
||||
|
||||
try
|
||||
{
|
||||
int result = client.executeMethod( get );
|
||||
if ( result == HttpStatus.SC_OK )
|
||||
{
|
||||
new MavenXpp3Reader().read( get.getResponseBodyAsStream() );
|
||||
String body = get.getResponseBodyAsString();
|
||||
new MavenXpp3Reader().read( new StringReader( body ) );
|
||||
isOffline = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println( "Got HTTP status of: " + result );
|
||||
System.out.println( "System is offline" );
|
||||
isOffline = true;
|
||||
}
|
||||
}
|
||||
catch ( HttpException e )
|
||||
{
|
||||
System.out.println( "Got error: " + e.getMessage() );
|
||||
System.out.println( "System is offline" );
|
||||
isOffline = true;
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
System.out.println( "Got error: " + e.getMessage() );
|
||||
System.out.println( "System is offline" );
|
||||
isOffline = true;
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
System.out.println( "Got error: " + e.getMessage() );
|
||||
System.out.println( "System is offline" );
|
||||
isOffline = true;
|
||||
}
|
||||
|
@ -152,37 +167,82 @@ public class ErrorReporterPointcutTest
|
|||
}
|
||||
}
|
||||
|
||||
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
|
||||
if ( testDirectory.exists() )
|
||||
{
|
||||
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
|
||||
}
|
||||
else
|
||||
{
|
||||
testDirectory.mkdirs();
|
||||
}
|
||||
|
||||
return targetDirectory;
|
||||
}
|
||||
|
||||
public void testHandleErrorBuildingExtensionPluginPOM()
|
||||
throws URISyntaxException
|
||||
private void buildTestAccessory( File basedir )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( new DummyCoreErrorReporter() )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"clean",
|
||||
"install"
|
||||
} ) );
|
||||
|
||||
MavenExecutionResult result = maven.execute( request );
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
reportExceptions( result, basedir );
|
||||
}
|
||||
}
|
||||
|
||||
public void testHandleProjectBuildingError()
|
||||
private void reportExceptions( MavenExecutionResult result, File basedir )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter pWriter = new PrintWriter( writer );
|
||||
|
||||
writer.write( "Failed to build project in: " );
|
||||
writer.write( basedir.getPath() );
|
||||
writer.write( "\nEncountered the following errors:" );
|
||||
|
||||
for ( Iterator it = result.getExceptions().iterator(); it.hasNext(); )
|
||||
{
|
||||
Throwable error = (Throwable) it.next();
|
||||
writer.write( "\n\n" );
|
||||
error.printStackTrace( pWriter );
|
||||
}
|
||||
|
||||
fail( writer.toString() );
|
||||
}
|
||||
|
||||
public void testHandleSuperPomBuildingError_XmlPullParserException()
|
||||
// FIXME: Figure out how to keep the project-build error report from being the primary report...
|
||||
public void testReportErrorResolvingExtensionDirectDependencies()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// File projectDir = prepareProjectDir();
|
||||
// File localRepo = new File( projectDir, "local-repo" );
|
||||
// File project = new File( projectDir, "project" );
|
||||
//
|
||||
// reporter.reportErrorResolvingExtensionDirectDependencies( null, null, null, null, null );
|
||||
// reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
// reporterCtl.setVoidCallable();
|
||||
//
|
||||
// reporterCtl.replay();
|
||||
//
|
||||
// MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
|
||||
// .setLocalRepositoryPath( localRepo )
|
||||
// .setShowErrors( true )
|
||||
// .setErrorReporter( reporter )
|
||||
// .setGoals( Arrays.asList( new String[] {
|
||||
// "initialize"
|
||||
// } ) );
|
||||
//
|
||||
// maven.execute( request );
|
||||
//
|
||||
// reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testHandleSuperPomBuildingError_IOException()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
// FIXME: Fix the offline detection for this one!
|
||||
public void testReportAggregatedMojoFailureException()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
|
@ -215,38 +275,6 @@ public class ErrorReporterPointcutTest
|
|||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
private void buildTestAccessory( File basedir )
|
||||
{
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( new DummyCoreErrorReporter() )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"clean",
|
||||
"install"
|
||||
} ) );
|
||||
|
||||
MavenExecutionResult result = maven.execute( request );
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter pWriter = new PrintWriter( writer );
|
||||
|
||||
writer.write( "Failed to build project in: " );
|
||||
writer.write( basedir.getPath() );
|
||||
writer.write( "\nEncountered the following errors:" );
|
||||
|
||||
for ( Iterator it = result.getExceptions().iterator(); it.hasNext(); )
|
||||
{
|
||||
Throwable error = (Throwable) it.next();
|
||||
writer.write( "\n\n" );
|
||||
error.printStackTrace( pWriter );
|
||||
}
|
||||
|
||||
fail( writer.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testReportAttemptToOverrideUneditableMojoParameter()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -260,15 +288,62 @@ public class ErrorReporterPointcutTest
|
|||
}
|
||||
|
||||
public void testReportErrorConfiguringExtensionPluginRealm()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
File projectDir = prepareProjectDir();
|
||||
|
||||
buildTestAccessory( new File( projectDir, "plugin" ) );
|
||||
|
||||
File project = new File( projectDir, "project" );
|
||||
|
||||
reporter.reportErrorConfiguringExtensionPluginRealm( null, null, null, null, (PluginManagerException) null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"initialize"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportErrorFormulatingBuildPlan()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
if ( !checkOnline() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
File projectDir = prepareProjectDir();
|
||||
|
||||
buildTestAccessory( new File( projectDir, "plugin" ) );
|
||||
|
||||
File basedir = new File( projectDir, "project" );
|
||||
|
||||
reporter.reportErrorFormulatingBuildPlan( null, null, null, null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"org.apache.maven.errortest:testReportErrorFormulatingBuildPlan-maven-plugin:1:test"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportErrorInterpolatingModel_UsingProjectInstance()
|
||||
|
@ -284,27 +359,56 @@ public class ErrorReporterPointcutTest
|
|||
}
|
||||
|
||||
public void testReportErrorManagingRealmForExtension()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
File projectDir = prepareProjectDir();
|
||||
|
||||
}
|
||||
buildTestAccessory( new File( projectDir, "ext" ) );
|
||||
|
||||
public void testReportErrorManagingRealmForExtensionPlugin()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
File project = new File( projectDir, "project" );
|
||||
|
||||
reporter.reportErrorManagingRealmForExtension( null, null, null, null, null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"initialize"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportErrorResolvingExtensionDependencies()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
File projectDir = prepareProjectDir();
|
||||
File localRepo = new File( projectDir, "local-repo" );
|
||||
File project = new File( projectDir, "project" );
|
||||
|
||||
}
|
||||
reporter.reportErrorResolvingExtensionDependencies( null, null, null, null, null, null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
public void testReportErrorResolvingExtensionDirectDependencies()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
|
||||
.setLocalRepositoryPath( localRepo )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"initialize"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportErrorSearchingforCompatibleExtensionPluginVersion()
|
||||
|
@ -338,9 +442,26 @@ public class ErrorReporterPointcutTest
|
|||
}
|
||||
|
||||
public void testReportInvalidMavenVersion()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
File projectDir = prepareProjectDir();
|
||||
|
||||
reporter.reportInvalidMavenVersion( null, null, null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
|
||||
.setShowErrors( true )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"initialize"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportInvalidPluginExecutionEnvironment()
|
||||
|
@ -367,15 +488,52 @@ public class ErrorReporterPointcutTest
|
|||
}
|
||||
|
||||
public void testReportLifecycleLoaderErrorWhileValidatingTask()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
File projectDir = prepareProjectDir();
|
||||
File localRepo = new File( projectDir, "local-repo" );
|
||||
|
||||
Settings settings = new Settings();
|
||||
settings.setLocalRepository( localRepo.getAbsolutePath() );
|
||||
settings.setOffline( true );
|
||||
|
||||
reporter.reportLifecycleLoaderErrorWhileValidatingTask( null, null, null, null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
|
||||
.setShowErrors( true )
|
||||
.setLoggingLevel( Logger.LEVEL_DEBUG )
|
||||
.setSettings( settings )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"invalid:test"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportLifecycleSpecErrorWhileValidatingTask()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
reporter.reportLifecycleSpecErrorWhileValidatingTask( null, null, null, null );
|
||||
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
reporterCtl.setVoidCallable();
|
||||
|
||||
reporterCtl.replay();
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
|
||||
.setErrorReporter( reporter )
|
||||
.setGoals( Arrays.asList( new String[] {
|
||||
"name:of:invalid:direct:mojo:for:test"
|
||||
} ) );
|
||||
|
||||
maven.execute( request );
|
||||
|
||||
reporterCtl.verify();
|
||||
}
|
||||
|
||||
public void testReportMissingArtifactWhileAddingExtensionPlugin()
|
||||
|
@ -431,18 +589,6 @@ public class ErrorReporterPointcutTest
|
|||
|
||||
}
|
||||
|
||||
public void testReportPomFileCanonicalizationError()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void testReportPomFileScanningError()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void testReportProjectCycle()
|
||||
throws URISyntaxException, IOException
|
||||
{
|
||||
|
|
|
@ -127,6 +127,12 @@ public class MavenMetadataSource
|
|||
}
|
||||
catch ( InvalidProjectModelException e )
|
||||
{
|
||||
if ( strictlyEnforceThePresenceOfAValidMavenPOM )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Invalid POM file for artifact: '" +
|
||||
artifact.getDependencyConflictId() + "' Reason: " + e.getMessage(), e, artifact );
|
||||
}
|
||||
|
||||
getLogger().warn( "POM for \'" + pomArtifact +
|
||||
"\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() );
|
||||
|
||||
|
|
|
@ -261,6 +261,23 @@ under the License.
|
|||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
|
||||
<role-hint>maven-strict</role-hint>
|
||||
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
|
||||
<configuration>
|
||||
<strictlyEnforceThePresenceOfAValidMavenPOM>true</strictlyEnforceThePresenceOfAValidMavenPOM>
|
||||
</configuration>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
|
||||
<role-hint>default</role-hint>
|
||||
|
|
Loading…
Reference in New Issue