diff --git a/maven-core/src/main/aspect/org/apache/maven/errors/AbstractCoreReporterAspect.aj b/maven-core/src/main/aspect/org/apache/maven/errors/AbstractCoreReporterAspect.aj
index 9f687d2747..ca383750d3 100644
--- a/maven-core/src/main/aspect/org/apache/maven/errors/AbstractCoreReporterAspect.aj
+++ b/maven-core/src/main/aspect/org/apache/maven/errors/AbstractCoreReporterAspect.aj
@@ -3,6 +3,9 @@ package org.apache.maven.errors;
public abstract aspect AbstractCoreReporterAspect
{
+ protected pointcut notWithinAspect():
+ !within( *.*Aspect+ );
+
protected CoreErrorReporter getReporter()
{
return CoreReporterManager.getReporter();
diff --git a/maven-core/src/main/aspect/org/apache/maven/errors/BuildFailureReporterAspect.aj b/maven-core/src/main/aspect/org/apache/maven/errors/BuildFailureReporterAspect.aj
index 9e056f12b7..7bfe43cd30 100644
--- a/maven-core/src/main/aspect/org/apache/maven/errors/BuildFailureReporterAspect.aj
+++ b/maven-core/src/main/aspect/org/apache/maven/errors/BuildFailureReporterAspect.aj
@@ -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
*
*
*/
- 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
*
*
*/
- 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:
*
@@ -150,13 +163,12 @@ public aspect BuildFailureReporterAspect
*
*
*/
- 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
*
*
*/
- 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 );
}
}
diff --git a/maven-core/src/main/aspect/org/apache/maven/errors/ExtensionErrorReporterAspect.aj b/maven-core/src/main/aspect/org/apache/maven/errors/ExtensionErrorReporterAspect.aj
index 234932c215..8f7c5d1ad9 100644
--- a/maven-core/src/main/aspect/org/apache/maven/errors/ExtensionErrorReporterAspect.aj
+++ b/maven-core/src/main/aspect/org/apache/maven/errors/ExtensionErrorReporterAspect.aj
@@ -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 ):
diff --git a/maven-core/src/main/aspect/org/apache/maven/errors/MavenExecErrorReporterAspect.aj b/maven-core/src/main/aspect/org/apache/maven/errors/MavenExecErrorReporterAspect.aj
index 1d97379e74..6b115a9c16 100644
--- a/maven-core/src/main/aspect/org/apache/maven/errors/MavenExecErrorReporterAspect.aj
+++ b/maven-core/src/main/aspect/org/apache/maven/errors/MavenExecErrorReporterAspect.aj
@@ -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 );
- }
-
}
diff --git a/maven-core/src/main/java/org/apache/maven/errors/CoreErrorReporter.java b/maven-core/src/main/java/org/apache/maven/errors/CoreErrorReporter.java
index bb35e527a9..3942a492e7 100644
--- a/maven-core/src/main/java/org/apache/maven/errors/CoreErrorReporter.java
+++ b/maven-core/src/main/java/org/apache/maven/errors/CoreErrorReporter.java
@@ -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 );
diff --git a/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java b/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
index 692c66fb61..28d2c612d0 100644
--- a/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
+++ b/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
@@ -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;
diff --git a/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java b/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
index 91f178eeb6..497a86a7bb 100644
--- a/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
+++ b/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
@@ -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,
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
index 7fe6bbb6bb..91de544c2b 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
@@ -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;
diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml
index b5f8bfed49..3f7a86b33f 100644
--- a/maven-core/src/main/resources/META-INF/plexus/components.xml
+++ b/maven-core/src/main/resources/META-INF/plexus/components.xml
@@ -262,7 +262,7 @@ under the License.
org.apache.maven.artifact.metadata.ArtifactMetadataSource
- default
+ maven-strict
org.apache.maven.artifact.manager.WagonManager
diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
index d56b82ea08..5ccf2eb42b 100644
--- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
+++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
@@ -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();
}
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml
index 9c9c849c58..d6d43709a1 100644
--- a/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml
+++ b/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml
@@ -24,12 +24,12 @@ under the License.
1
-
-
+
+
junit
junit
[3.1,
-
-
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/pom.xml
new file mode 100644
index 0000000000..9235a1c1c9
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/pom.xml
@@ -0,0 +1,14 @@
+
+ 4.0.0
+ org.apache.maven.errortest
+ test-maven-ext-plugin
+ maven-plugin
+ 1
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.1-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/ComponentOne.java b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/ComponentOne.java
new file mode 100644
index 0000000000..49b7686e7e
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/ComponentOne.java
@@ -0,0 +1,8 @@
+package org.plugin;
+
+public class ComponentOne
+{
+
+ private ComponentTwo two;
+
+}
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/ComponentTwo.java b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/ComponentTwo.java
new file mode 100644
index 0000000000..0a82f57898
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/ComponentTwo.java
@@ -0,0 +1,8 @@
+package org.plugin;
+
+public class ComponentTwo
+{
+
+ private ComponentOne one;
+
+}
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/TestPlugin.java b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/TestPlugin.java
new file mode 100644
index 0000000000..4b4a1e4d51
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/java/org/plugin/TestPlugin.java
@@ -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;
+ }
+
+}
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/resources/META-INF/plexus/components.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000000..4bc809e784
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/plugin/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,25 @@
+
+
+
+ org.test.ComponentOne
+ default
+ org.test.ComponentOne
+
+
+ org.test.ComponentTwo
+
+
+
+
+
+ org.test.ComponentTwo
+ default
+ org.test.ComponentTwo
+
+
+ org.test.ComponentOne
+
+
+
+
+
\ No newline at end of file
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/project/pom.xml
new file mode 100644
index 0000000000..7455053be7
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorConfiguringExtensionPluginRealm/project/pom.xml
@@ -0,0 +1,36 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ testReportErrorConfiguringExtensionPluginRealm
+ 1
+
+
+
+
+ org.apache.maven.errortest
+ test-maven-ext-plugin
+ 1
+ true
+
+
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/plugin/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/plugin/pom.xml
new file mode 100644
index 0000000000..e6de627cd4
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/plugin/pom.xml
@@ -0,0 +1,14 @@
+
+ 4.0.0
+ org.apache.maven.errortest
+ testReportErrorFormulatingBuildPlan-maven-plugin
+ maven-plugin
+ 1
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.1-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/plugin/src/main/java/org/plugin/TestPlugin.java b/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/plugin/src/main/java/org/plugin/TestPlugin.java
new file mode 100644
index 0000000000..b5e6ecd53e
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/plugin/src/main/java/org/plugin/TestPlugin.java
@@ -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;
+ }
+
+}
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/project/pom.xml
new file mode 100644
index 0000000000..3653e8966c
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorFormulatingBuildPlan/project/pom.xml
@@ -0,0 +1,25 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ testReportErrorFormulatingBuildPlan
+ 1
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/pom.xml
new file mode 100644
index 0000000000..5e3148a5b8
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/pom.xml
@@ -0,0 +1,7 @@
+
+ 4.0.0
+ org.apache.maven.errortest
+ test-maven-ext
+ 1
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/src/main/java/org/ext/App.java b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/src/main/java/org/ext/App.java
new file mode 100644
index 0000000000..85ab5c4075
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/src/main/java/org/ext/App.java
@@ -0,0 +1,13 @@
+package org.ext;
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+{
+ public static void main( String[] args )
+ {
+ System.out.println( "Hello World!" );
+ }
+}
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/src/main/resources/META-INF/plexus/components.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000000..18664051d5
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/ext/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1 @@
+this is an error.
\ No newline at end of file
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/project/pom.xml
new file mode 100644
index 0000000000..ff4cd64a17
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorManagingRealmForExtension/project/pom.xml
@@ -0,0 +1,35 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ testReportErrorManagingRealmForExtension
+ 1
+
+
+
+
+ org.apache.maven.errortest
+ test-maven-ext
+ 1
+
+
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom
new file mode 100644
index 0000000000..71edcf4df5
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom
@@ -0,0 +1,26 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ test-maven-ext-dep
+ 1
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom
new file mode 100644
index 0000000000..cd40200d59
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom
@@ -0,0 +1,34 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ test-maven-ext
+ 1
+
+
+
+ org.apache.maven.errortest
+ test-maven-ext-dep
+ 1
+
+
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/project/pom.xml
new file mode 100644
index 0000000000..7f9767eec2
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDependencies/project/pom.xml
@@ -0,0 +1,35 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ testReportErrorResolvingExtensionDependencies
+ 1
+
+
+
+
+ org.apache.maven.errortest
+ test-maven-ext
+ 1
+
+
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDirectDependencies/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDirectDependencies/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom
new file mode 100644
index 0000000000..dcaf397e55
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDirectDependencies/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom
@@ -0,0 +1,34 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ test-maven-ext
+ 1
+
+
+
+ junit
+ junit
+ [3.8,
+
+
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDirectDependencies/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDirectDependencies/project/pom.xml
new file mode 100644
index 0000000000..5d8caa81a3
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorResolvingExtensionDirectDependencies/project/pom.xml
@@ -0,0 +1,35 @@
+
+
+
+ 4.0.0
+ org.apache.maven.errortest
+ testReportErrorResolvingExtensionDirectDependencies
+ 1
+
+
+
+
+ org.apache.maven.errortest
+ test-maven-ext
+ 1
+
+
+
+
diff --git a/maven-embedder/src/test/error-reporting-projects/testReportInvalidMavenVersion/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportInvalidMavenVersion/pom.xml
new file mode 100644
index 0000000000..ef299bc4e6
--- /dev/null
+++ b/maven-embedder/src/test/error-reporting-projects/testReportInvalidMavenVersion/pom.xml
@@ -0,0 +1,11 @@
+
+ 4.0.0
+ org.apache.maven.errortest
+ testReportInvalidMavenVersion
+ 1
+
+
+ 10
+
+
+
\ No newline at end of file
diff --git a/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java b/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java
index 2808626afd..339c1b9469 100644
--- a/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java
@@ -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
{
diff --git a/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index a73943ee14..ea6139fe63 100644
--- a/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -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() );
diff --git a/maven-project/src/main/resources/META-INF/plexus/components.xml b/maven-project/src/main/resources/META-INF/plexus/components.xml
index c8007c4529..cb81eda211 100644
--- a/maven-project/src/main/resources/META-INF/plexus/components.xml
+++ b/maven-project/src/main/resources/META-INF/plexus/components.xml
@@ -261,6 +261,23 @@ under the License.
+
+ org.apache.maven.artifact.metadata.ArtifactMetadataSource
+ maven-strict
+ org.apache.maven.project.artifact.MavenMetadataSource
+
+ true
+
+
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
+
+ org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager
+
+
+
+
org.apache.maven.artifact.metadata.ArtifactMetadataSource
default