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 70eda5868b..234932c215 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 @@ -84,13 +84,16 @@ public privileged aspect ExtensionErrorReporterAspect getReporter().reportErrorResolvingExtensionDirectDependencies( extensionArtifact, projectArtifact, remoteRepos, request, cause ); } - before( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err ): + ExtensionManagerException around( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult ): cflow( dem_addExtension( extensionArtifact, projectArtifact, remoteRepos, request ) ) - && execution( ExtensionManagerException.new( .., ArtifactResolutionResult ) ) + && call( ExtensionManagerException.new( .., ArtifactResolutionResult ) ) && args( .., resolutionResult ) - && this( err ) { + ExtensionManagerException err = proceed( extensionArtifact, projectArtifact, remoteRepos, request, resolutionResult ); + getReporter().reportErrorResolvingExtensionDependencies( extensionArtifact, projectArtifact, remoteRepos, request, resolutionResult, err ); + + return err; } private pointcut call_eme_ctor_RealmManagementException( RealmManagementException cause ): @@ -214,27 +217,17 @@ public privileged aspect ExtensionErrorReporterAspect cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) ) && cflow( execution( * PluginManager+.verifyPlugin( .. ) ) ) && cflow( dpm_verifyVersionedPlugin( plugin ) ) - && execution( PluginVersionResolutionException.new( .., String ) ) + && call( PluginVersionResolutionException.new( .., String ) ) && this( err ) { getReporter().reportIncompatibleMavenVersionForExtensionPlugin( plugin, originModel, remoteRepos, request, requiredVersion, currentVersion, err ); } - before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ProjectBuildingException cause ): - cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) ) - && cflow( execution( * PluginManager+.verifyPlugin( .. ) ) ) - && cflow( dpm_verifyVersionedPlugin( plugin ) ) - && execution( InvalidPluginException.new( .., ProjectBuildingException ) ) - && args( .., cause ) - { - getReporter().handleErrorBuildingExtensionPluginPOM( plugin, originModel, remoteRepos, request, cause ); - } - before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause ): cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) ) && cflow( execution( * PluginManager+.verifyPlugin( .. ) ) ) && cflow( dpm_verifyVersionedPlugin( plugin ) ) - && execution( InvalidPluginException.new( .., InvalidDependencyVersionException ) ) + && call( InvalidPluginException.new( .., InvalidDependencyVersionException ) ) && args( .., cause ) { getReporter().reportInvalidDependencyVersionInExtensionPluginPOM( plugin, originModel, remoteRepos, request, 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 b1c85c18aa..bb35e527a9 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 @@ -33,7 +33,6 @@ import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.loader.PluginLoaderException; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; @@ -55,37 +54,67 @@ public interface CoreErrorReporter extends ProjectErrorReporter { - void reportNoGoalsSpecifiedException( MavenProject rootProject, NoGoalsSpecifiedException error ); + void handleSuperPomBuildingError( ProjectBuildingException exception ); void reportAggregatedMojoFailureException( MavenSession session, MojoBinding binding, MojoFailureException cause ); - void reportProjectMojoFailureException( MavenSession session, MojoBinding binding, MojoFailureException cause ); + void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, MavenSession session, MojoExecution exec, PathTranslator translator, Logger logger, PluginConfigurationException cause ); - void reportProjectCycle( ProjectCycleException error ); + void reportErrorApplyingMojoConfiguration( MojoBinding binding, MavenProject project, PlexusConfiguration config, PluginConfigurationException cause ); - void reportPluginErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, PluginLoaderException cause, TaskValidationResult result ); + void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause ); - void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause, TaskValidationResult result ); + void reportErrorFormulatingBuildPlan( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause ); - void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleLoaderException cause, TaskValidationResult result ); + void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause ); - void reportMissingPluginDescriptor( MojoBinding binding, MavenProject project, LifecycleExecutionException err ); + void reportErrorLoadingPlugin( MojoBinding binding, MavenProject project, PluginLoaderException cause ); - void reportMojoExecutionException( MojoBinding binding, MavenProject project, MojoExecutionException cause ); + 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 ); + + void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, InvalidVersionSpecificationException cause ); + + void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause ); + + void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause ); + + void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, PluginVersionResolutionException err ); + + void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause ); + + void reportInvalidMavenVersion( MavenProject project, ArtifactVersion mavenVersion, MavenExecutionException err ); void reportInvalidPluginExecutionEnvironment( MojoBinding binding, MavenProject project, PluginExecutionException cause ); - void reportMojoLookupError( MojoBinding binding, MavenProject project, ComponentLookupException cause ); + void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleLoaderException cause, TaskValidationResult result ); - void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, MavenSession session, MojoExecution exec, PathTranslator translator, Logger logger, PluginConfigurationException cause ); + void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause, TaskValidationResult result ); + + void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause ); + + void reportMissingPluginDescriptor( MojoBinding binding, MavenProject project, LifecycleExecutionException err ); void reportMissingRequiredMojoParameter( MojoBinding binding, MavenProject project, List invalidParameters, PluginParameterException err ); - void reportUseOfBannedMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, String altExpression, ExpressionEvaluationException err ); + void reportMojoExecutionException( MojoBinding binding, MavenProject project, MojoExecutionException cause ); - void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, Exception cause ); + void reportMojoLookupError( MojoBinding binding, MavenProject project, ComponentLookupException cause ); - void reportErrorApplyingMojoConfiguration( MojoBinding binding, MavenProject project, PlexusConfiguration config, PluginConfigurationException cause ); + 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 reportProjectCycle( ProjectCycleException error ); void reportProjectDependenciesNotFound( MavenProject project, String scope, ArtifactNotFoundException cause ); @@ -95,48 +124,14 @@ public interface CoreErrorReporter void reportProjectDependencyArtifactUnresolvable( MavenProject project, Artifact artifact, ArtifactResolutionException cause ); - void reportErrorLoadingPlugin( MojoBinding binding, MavenProject project, PluginLoaderException cause ); + void reportProjectMojoFailureException( MavenSession session, MojoBinding binding, MojoFailureException cause ); - void reportErrorFormulatingBuildPlan( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause ); - - void reportInvalidMavenVersion( MavenProject project, ArtifactVersion mavenVersion, MavenExecutionException err ); - - void reportPomFileScanningError( File basedir, String includes, String excludes, IOException cause ); - - void reportPomFileCanonicalizationError( File pomFile, IOException cause ); - - void handleSuperPomBuildingError( ProfileManager globalProfileManager, ProjectBuildingException exception ); - - void handleSuperPomBuildingError( ProjectBuildingException exception ); - - void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause ); - - void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause ); - - void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err ); - - 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 reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause ); + void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, Exception cause ); void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionException cause ); - void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause ); - void reportUnresolvableExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause ); - void handleErrorBuildingExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ProjectBuildingException cause ); - - void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause ); - - void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, InvalidVersionSpecificationException cause ); - - void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, PluginVersionResolutionException err ); - - void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause ); - - void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause ); + void reportUseOfBannedMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, String altExpression, ExpressionEvaluationException err ); } 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 2c7cd345d5..91f178eeb6 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 @@ -5,7 +5,6 @@ import org.apache.maven.ProjectCycleException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -40,7 +39,6 @@ import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.loader.PluginLoaderException; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; @@ -947,28 +945,6 @@ public class DefaultCoreErrorReporter registerBuildError( cause, writer.toString(), cause.getCause() ); } - public void handleSuperPomBuildingError( MavenExecutionRequest request, - ArtifactRepository localRepository, - ProfileManager globalProfileManager, - ProjectBuildingException exception ) - { - ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter(); - Throwable reportedException = projectReporter.findReportedException( exception ); - String formattedMessage = projectReporter.getFormattedMessage( reportedException ); - - registerBuildError( exception, formattedMessage, reportedException ); - } - - public void handleSuperPomBuildingError( ProfileManager globalProfileManager, - ProjectBuildingException exception ) - { - ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter(); - Throwable reportedException = projectReporter.findReportedException( exception ); - String formattedMessage = projectReporter.getFormattedMessage( reportedException ); - - registerBuildError( exception, formattedMessage, reportedException ); - } - public void handleSuperPomBuildingError( ProjectBuildingException exception ) { ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter(); @@ -1387,19 +1363,6 @@ public class DefaultCoreErrorReporter registerBuildError( cause, writer.toString(), cause.getCause() ); } - public void handleErrorBuildingExtensionPluginPOM( Plugin plugin, - Model originModel, - List remoteRepos, - MavenExecutionRequest request, - ProjectBuildingException cause ) - { - ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter(); - Throwable reportedException = projectReporter.findReportedException( cause ); - String formattedMessage = projectReporter.getFormattedMessage( reportedException ); - - registerBuildError( cause, formattedMessage, reportedException ); - } - public void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, diff --git a/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java b/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java index 411432daca..81a96f6783 100644 --- a/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java +++ b/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java @@ -407,7 +407,6 @@ public class DefaultBuildExtensionScanner } catch ( ProjectBuildingException e ) { - System.out.println( "blah" ); throw new ExtensionScanningException( "Error building model lineage in order to pre-scan for extensions: " + e.getMessage(), pom, e ); } diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 5118112342..b3b73805a1 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -86,6 +86,10 @@ under the License. easymock easymock + + commons-httpclient + commons-httpclient + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportActivatorError/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportActivatorError/pom.xml new file mode 100644 index 0000000000..d3cf9d0103 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportActivatorError/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + org.apache.maven + testReportActivatorError + 1 + + + + faulty + + + nothing + + bar + + + + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/plugin/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/plugin/pom.xml new file mode 100644 index 0000000000..39e4570070 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/plugin/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + org.apache.maven.errortest + testReportAggregatedMojoFailureException-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/testReportAggregatedMojoFailureException/plugin/src/main/java/org/plugin/TestPlugin.java b/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/plugin/src/main/java/org/plugin/TestPlugin.java new file mode 100644 index 0000000000..ec25183090 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/plugin/src/main/java/org/plugin/TestPlugin.java @@ -0,0 +1,36 @@ +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 + * @aggregator + * + * @author jdcasey + */ +public class TestPlugin + implements Mojo +{ + + private Log log; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + throw new MojoFailureException( this, "This mojo will always fail.", "This mojo is programmed to fail at all times, to express certain error-reporting functions." ); + } + + public Log getLog() + { + return log; + } + + public void setLog( Log log ) + { + this.log = log; + } + +} diff --git a/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/project/pom.xml new file mode 100644 index 0000000000..6b8138d1ba --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportAggregatedMojoFailureException/project/pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + org.apache.maven + testReportAggregatedMojoFailureException + 1 + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportBadDependencyVersion/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportBadDependencyVersion/pom.xml new file mode 100644 index 0000000000..d46f843876 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportBadDependencyVersion/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + org.apache.maven + testReportBadDependencyVersion + 1 + + + + junit + junit + [3.1, + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportBadManagedDependencyVersion/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportBadManagedDependencyVersion/pom.xml new file mode 100644 index 0000000000..ee59f8f419 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportBadManagedDependencyVersion/pom.xml @@ -0,0 +1,35 @@ + + + + 4.0.0 + org.apache.maven + testReportBadManagedDependencyVersion + 1 + + + + + junit + junit + [3.1, + + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml new file mode 100644 index 0000000000..9c9c849c58 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportBadNonDependencyProjectArtifactVersion/pom.xml @@ -0,0 +1,35 @@ + + + + 4.0.0 + org.apache.maven + testReportBadNonDependencyProjectArtifactVersion + 1 + + + + + junit + junit + [3.1, + + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorCreatingArtifactRepository/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorCreatingArtifactRepository/pom.xml new file mode 100644 index 0000000000..4c2b8b28f8 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorCreatingArtifactRepository/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + org.apache.maven + testReportErrorCreatingArtifactRepository + 1 + + + + junit + junit + 3.8.1 + + + + + + test + http://www.google.com + nothing + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportErrorCreatingDeploymentArtifactRepository/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportErrorCreatingDeploymentArtifactRepository/pom.xml new file mode 100644 index 0000000000..b52f311420 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportErrorCreatingDeploymentArtifactRepository/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + org.apache.maven + testReportErrorCreatingDeploymentArtifactRepository + 1 + + + + junit + junit + 3.8.1 + + + + + + test + http://www.google.com + nothing + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/mod1/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/mod1/pom.xml new file mode 100644 index 0000000000..5f1ed1090d --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/mod1/pom.xml @@ -0,0 +1,7 @@ + + 4.0.0 + + org.apache.maven.errortest + module + 1 + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/mod2/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/mod2/pom.xml new file mode 100644 index 0000000000..5f1ed1090d --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/mod2/pom.xml @@ -0,0 +1,7 @@ + + 4.0.0 + + org.apache.maven.errortest + module + 1 + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/pom.xml new file mode 100644 index 0000000000..52780700ee --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectCollision/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + org.apache.maven.errortest + testReportProjectCollision + 1 + pom + + + mod1 + mod2 + + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectCycle/dep/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectCycle/dep/pom.xml new file mode 100644 index 0000000000..d2fe529046 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectCycle/dep/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + + + org.apache.maven.errortest + testReportProjectCycle + 1 + + + org.apache.maven.errortest + testReportProjectCycle-dep + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectCycle/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectCycle/pom.xml new file mode 100644 index 0000000000..2dbf249eb2 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectCycle/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + org.apache.maven.errortest + testReportProjectCycle + 1 + pom + + + dep + + + + + org.apache.maven.errortest + testReportProjectCycle-dep + 1 + + + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectMojoFailureException/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectMojoFailureException/pom.xml index 53bb9788d7..cbbc587413 100644 --- a/maven-embedder/src/test/error-reporting-projects/testReportProjectMojoFailureException/pom.xml +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectMojoFailureException/pom.xml @@ -2,11 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 org.apache.maven.test.error - test-mojo-failure + testReportProjectMojoFailureException jar 1 - test-mojo-failure - http://maven.apache.org + junit diff --git a/maven-embedder/src/test/error-reporting-projects/testReportProjectValidationFailure/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportProjectValidationFailure/pom.xml new file mode 100644 index 0000000000..4e27c4d17c --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportProjectValidationFailure/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + org.apache.maven.errortest + testReportProjectValidationFailure + 1 + + + + junit + junit + + + \ No newline at end of file diff --git a/maven-embedder/src/test/java/org/apache/maven/error/DummyCoreErrorReporter.java b/maven-embedder/src/test/java/org/apache/maven/error/DummyCoreErrorReporter.java new file mode 100644 index 0000000000..9d844abb7f --- /dev/null +++ b/maven-embedder/src/test/java/org/apache/maven/error/DummyCoreErrorReporter.java @@ -0,0 +1,603 @@ +package org.apache.maven.error; + +import org.apache.maven.NoGoalsSpecifiedException; +import org.apache.maven.ProjectCycleException; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.InvalidRepositoryException; +import org.apache.maven.artifact.UnknownRepositoryLayoutException; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.errors.DefaultCoreErrorReporter; +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.execution.RealmManagementException; +import org.apache.maven.extension.ExtensionManagerException; +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.DeploymentRepository; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.Profile; +import org.apache.maven.model.Repository; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.PluginConfigurationException; +import org.apache.maven.plugin.PluginExecutionException; +import org.apache.maven.plugin.PluginManagerException; +import org.apache.maven.plugin.PluginNotFoundException; +import org.apache.maven.plugin.PluginParameterException; +import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.plugin.loader.PluginLoaderException; +import org.apache.maven.plugin.version.PluginVersionNotFoundException; +import org.apache.maven.plugin.version.PluginVersionResolutionException; +import org.apache.maven.profiles.activation.ProfileActivationContext; +import org.apache.maven.profiles.activation.ProfileActivationException; +import org.apache.maven.profiles.activation.ProfileActivator; +import org.apache.maven.project.DuplicateProjectException; +import org.apache.maven.project.InvalidProjectModelException; +import org.apache.maven.project.InvalidProjectVersionException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.artifact.InvalidDependencyVersionException; +import org.apache.maven.project.build.model.ModelAndFile; +import org.apache.maven.project.interpolation.ModelInterpolationException; +import org.apache.maven.project.path.PathTranslator; +import org.apache.maven.reactor.MavenExecutionException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class DummyCoreErrorReporter + extends DefaultCoreErrorReporter +{ + + public void handleSuperPomBuildingError( ProjectBuildingException exception ) + { + + + } + + public void reportAggregatedMojoFailureException( MavenSession session, + MojoBinding binding, + MojoFailureException cause ) + { + + + } + + public void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter, + MojoBinding binding, + MavenProject project, + MavenSession session, + MojoExecution exec, + PathTranslator translator, + Logger logger, + PluginConfigurationException cause ) + { + + + } + + public void reportErrorApplyingMojoConfiguration( MojoBinding binding, + MavenProject project, + PlexusConfiguration config, + PluginConfigurationException cause ) + { + + + } + + public void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + PluginManagerException cause ) + { + + + } + + public void reportErrorFormulatingBuildPlan( List tasks, + MavenProject configuringProject, + String targetDescription, + LifecycleException cause ) + { + + + } + + public void reportErrorInterpolatingModel( Model model, + Map inheritedValues, + File pomFile, + MavenExecutionRequest request, + ModelInterpolationException cause ) + { + + + } + + public void reportErrorLoadingPlugin( MojoBinding binding, + MavenProject project, + PluginLoaderException cause ) + { + + + } + + public void reportErrorManagingRealmForExtension( Artifact extensionArtifact, + Artifact projectArtifact, + List remoteRepos, + MavenExecutionRequest request, + RealmManagementException cause ) + { + + + } + + public void reportErrorManagingRealmForExtensionPlugin( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + RealmManagementException cause ) + { + + + } + + public void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact, + Artifact projectArtifact, + List remoteRepos, + MavenExecutionRequest request, + ArtifactResolutionResult resolutionResult, + ExtensionManagerException err ) + { + + + } + + public void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact, + Artifact projectArtifact, + List remoteRepos, + MavenExecutionRequest request, + ArtifactMetadataRetrievalException cause ) + { + + + } + + public void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + String requiredMavenVersion, + String currentMavenVersion, + InvalidVersionSpecificationException cause ) + { + + + } + + public void reportExtensionPluginArtifactNotFound( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + PluginNotFoundException cause ) + { + + + } + + public void reportExtensionPluginVersionNotFound( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + PluginVersionNotFoundException cause ) + { + + + } + + public void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + String requiredMavenVersion, + String currentMavenVersion, + PluginVersionResolutionException err ) + { + + + } + + public void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + InvalidDependencyVersionException cause ) + { + + + } + + public void reportInvalidMavenVersion( MavenProject project, + ArtifactVersion mavenVersion, + MavenExecutionException err ) + { + + + } + + public void reportInvalidPluginExecutionEnvironment( MojoBinding binding, + MavenProject project, + PluginExecutionException cause ) + { + + + } + + public void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session, + MavenProject rootProject, + LifecycleLoaderException cause, + TaskValidationResult result ) + { + + + } + + public void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session, + MavenProject rootProject, + LifecycleSpecificationException cause, + TaskValidationResult result ) + { + + + } + + public void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + ArtifactNotFoundException cause ) + { + + + } + + public void reportMissingPluginDescriptor( MojoBinding binding, + MavenProject project, + LifecycleExecutionException err ) + { + + + } + + public void reportMissingRequiredMojoParameter( MojoBinding binding, + MavenProject project, + List invalidParameters, + PluginParameterException err ) + { + + + } + + public void reportMojoExecutionException( MojoBinding binding, + MavenProject project, + MojoExecutionException cause ) + { + + + } + + public void reportMojoLookupError( MojoBinding binding, + MavenProject project, + ComponentLookupException cause ) + { + + + } + + public void reportNoGoalsSpecifiedException( MavenProject rootProject, + NoGoalsSpecifiedException error ) + { + + + } + + public void reportPluginErrorWhileValidatingTask( MavenSession session, + MavenProject rootProject, + PluginLoaderException cause, + TaskValidationResult result ) + { + + + } + + public void reportPomFileCanonicalizationError( File pomFile, + IOException cause ) + { + + + } + + public void reportPomFileScanningError( File basedir, + String includes, + String excludes, + IOException cause ) + { + + + } + + public void reportProjectCycle( ProjectCycleException error ) + { + + + } + + public void reportProjectDependenciesNotFound( MavenProject project, + String scope, + ArtifactNotFoundException cause ) + { + + + } + + public void reportProjectDependenciesUnresolvable( MavenProject project, + String scope, + ArtifactResolutionException cause ) + { + + + } + + public void reportProjectDependencyArtifactNotFound( MavenProject project, + Artifact artifact, + ArtifactNotFoundException cause ) + { + + + } + + public void reportProjectDependencyArtifactUnresolvable( MavenProject project, + Artifact artifact, + ArtifactResolutionException cause ) + { + + + } + + public void reportProjectMojoFailureException( MavenSession session, + MojoBinding binding, + MojoFailureException cause ) + { + + + } + + public void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter, + MojoBinding binding, + MavenProject project, + String expression, + Exception cause ) + { + + + } + + public void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + ArtifactResolutionException cause ) + { + + + } + + public void reportUnresolvableExtensionPluginPOM( Plugin plugin, + Model originModel, + List remoteRepos, + MavenExecutionRequest request, + ArtifactMetadataRetrievalException cause ) + { + + + } + + public void reportUseOfBannedMojoParameter( Parameter currentParameter, + MojoBinding binding, + MavenProject project, + String expression, + String altExpression, + ExpressionEvaluationException err ) + { + + + } + + public void reportActivatorError( ProfileActivator activator, + String projectId, + File pomFile, + Profile profile, + ProfileActivationContext context, + ProfileActivationException cause ) + { + + + } + + public void reportActivatorLookupError( String projectId, + File pomFile, + Profile profile, + ComponentLookupException cause ) + { + + + } + + public void reportBadDependencyVersion( MavenProject project, + File pomFile, + InvalidDependencyVersionException cause ) + { + + + } + + public void reportBadManagedDependencyVersion( MavenProject projectBeingBuilt, + File pomFile, + InvalidDependencyVersionException cause ) + { + + + } + + public void reportBadNonDependencyProjectArtifactVersion( MavenProject project, + File pomFile, + InvalidProjectVersionException cause ) + { + + + } + + public void reportErrorCreatingArtifactRepository( MavenProject project, + File pomFile, + Repository repo, + UnknownRepositoryLayoutException cause, + boolean isPluginRepo ) + { + + + } + + public void reportErrorCreatingDeploymentArtifactRepository( MavenProject project, + File pomFile, + DeploymentRepository repo, + UnknownRepositoryLayoutException cause ) + { + + + } + + public void reportErrorInterpolatingModel( MavenProject project, + File pomFile, + ModelInterpolationException cause ) + { + + + } + + public void reportErrorLoadingExternalProfilesFromFile( Model model, + File pomFile, + File projectDir, + IOException cause ) + { + + + } + + public void reportErrorLoadingExternalProfilesFromFile( Model model, + File pomFile, + File projectDir, + XmlPullParserException cause ) + { + + + } + + public void reportErrorParsingParentProjectModel( ModelAndFile childInfo, + File parentPomFile, + XmlPullParserException cause ) + { + + + } + + public void reportErrorParsingParentProjectModel( ModelAndFile childInfo, + File parentPomFile, + IOException cause ) + { + + + } + + public void reportErrorParsingProjectModel( String projectId, + File pomFile, + XmlPullParserException cause ) + { + + + } + + public void reportErrorParsingProjectModel( String projectId, + File pomFile, + IOException cause ) + { + + + } + + public void reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( Repository repo, + String projectId, + File pomFile, + InvalidRepositoryException cause ) + { + + + } + + public void reportParentPomArtifactNotFound( Parent parentRef, + ArtifactRepository localRepo, + List remoteRepos, + String childId, + File childPomFile, + ArtifactNotFoundException cause ) + { + + + } + + public void reportParentPomArtifactUnresolvable( Parent parentRef, + ArtifactRepository localRepo, + List remoteRepos, + String childId, + File childPomFile, + ArtifactResolutionException cause ) + { + + + } + + public void reportProjectCollision( List allProjectInstances, + DuplicateProjectException err ) + { + + + } + + public void reportProjectValidationFailure( MavenProject project, + File pomFile, + InvalidProjectModelException error ) + { + + + } + +} 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 a566fa66f4..2808626afd 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 @@ -1,5 +1,10 @@ package org.apache.maven.error; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpConnectionManager; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.methods.GetMethod; import org.apache.maven.embedder.Configuration; import org.apache.maven.embedder.DefaultConfiguration; import org.apache.maven.embedder.MavenEmbedder; @@ -7,6 +12,8 @@ import org.apache.maven.embedder.MavenEmbedderConsoleLogger; import org.apache.maven.errors.CoreErrorReporter; 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.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; @@ -14,8 +21,12 @@ import org.easymock.MockControl; import java.io.File; import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.net.URISyntaxException; import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; import junit.framework.TestCase; @@ -31,6 +42,10 @@ public class ErrorReporterPointcutTest private String basedir; + private static boolean isOffline; + + private static boolean offlineIsSet = false; + public void setUp() throws Exception { @@ -57,10 +72,68 @@ public class ErrorReporterPointcutTest maven = new MavenEmbedder( configuration ); } + private boolean checkOnline() + { + if ( !offlineIsSet ) + { + HttpClient client = new HttpClient(); + GetMethod get = new GetMethod( + "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 ); + + try + { + int result = client.executeMethod( get ); + if ( result == HttpStatus.SC_OK ) + { + new MavenXpp3Reader().read( get.getResponseBodyAsStream() ); + isOffline = false; + } + } + catch ( HttpException e ) + { + System.out.println( "System is offline" ); + isOffline = true; + } + catch ( IOException e ) + { + System.out.println( "System is offline" ); + isOffline = true; + } + catch ( XmlPullParserException e ) + { + System.out.println( "System is offline" ); + isOffline = true; + } + finally + { + offlineIsSet = true; + } + } + + if ( isOffline ) + { + String method = getTestMethodName(); + System.out.println( "Test: " + method + + " requires an access to the Maven central repository. SKIPPING." ); + return false; + } + + return true; + } + + private String getTestMethodName() + { + String method = new Throwable().getStackTrace()[2].getMethodName(); + return method; + } + private File prepareProjectDir() throws URISyntaxException, IOException { - String method = new Throwable().getStackTrace()[1].getMethodName(); + String method = getTestMethodName(); String resource = "error-reporting-projects/" + method; @@ -74,8 +147,9 @@ public class ErrorReporterPointcutTest { FileUtils.deleteDirectory( targetDirectory ); } - catch( IOException e ) - {} + catch ( IOException e ) + { + } } FileUtils.copyDirectoryStructure( testDirectory, targetDirectory ); @@ -108,10 +182,69 @@ public class ErrorReporterPointcutTest } + // FIXME: Fix the offline detection for this one! public void testReportAggregatedMojoFailureException() + 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.reportAggregatedMojoFailureException( 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:testReportAggregatedMojoFailureException-maven-plugin:1:test" + } ) ); + + maven.execute( request ); + + 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() @@ -277,8 +410,19 @@ public class ErrorReporterPointcutTest public void testReportNoGoalsSpecifiedException() { - // TODO Auto-generated method stub + reporter.reportNoGoalsSpecifiedException( null, null ); + reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER ); + reporterCtl.setVoidCallable(); + reporterCtl.replay(); + + MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true ) + .setErrorReporter( reporter ) + .setGoals( Collections.EMPTY_LIST ); + + maven.execute( request ); + + reporterCtl.verify(); } public void testReportPluginErrorWhileValidatingTask() @@ -300,9 +444,26 @@ public class ErrorReporterPointcutTest } public void testReportProjectCycle() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportProjectCycle( 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 testReportProjectDependenciesNotFound() @@ -377,82 +538,149 @@ public class ErrorReporterPointcutTest } - public void clearErrors() + // FIXME: How can I test this when it's masked by reportActivatorErrorWhileGettingRepositoriesFromProfiles? + public void testReportActivatorError() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportActivatorError( null, null, null, 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 Throwable findReportedException( Throwable error ) - { - // TODO Auto-generated method stub - return null; - } - - public String getFormattedMessage( Throwable error ) - { - // TODO Auto-generated method stub - return null; - } - - public Throwable getRealCause( Throwable error ) - { - // TODO Auto-generated method stub - return null; - } - - public void testReportActivatorErrorWhileApplyingProfiles() - { - // TODO Auto-generated method stub - - } - - public void testReportActivatorErrorWhileGettingRepositoriesFromProfiles() - { - // TODO Auto-generated method stub - - } - - public void testReportActivatorLookupErrorWhileApplyingProfiles() - { - // TODO Auto-generated method stub - - } - - public void testReportActivatorLookupErrorWhileGettingRepositoriesFromProfiles() + public void testReportActivatorLookupError() { // TODO Auto-generated method stub } public void testReportBadDependencyVersion() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportBadDependencyVersion( 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[] { + "compile" + } ) ); + + maven.execute( request ); + + reporterCtl.verify(); } public void testReportBadManagedDependencyVersion() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportBadManagedDependencyVersion( 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 testReportBadNonDependencyProjectArtifactVersion() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportBadNonDependencyProjectArtifactVersion( 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 testReportErrorCreatingArtifactRepository() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportErrorCreatingArtifactRepository( null, 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[] { + "compile" + } ) ); + + maven.execute( request ); + + reporterCtl.verify(); } public void testReportErrorCreatingDeploymentArtifactRepository() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportErrorCreatingDeploymentArtifactRepository( null, 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[] { + "compile" + } ) ); + + maven.execute( request ); + + reporterCtl.verify(); } public void testReportErrorInterpolatingModel_UsingModelInstance() @@ -520,7 +748,9 @@ public class ErrorReporterPointcutTest reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File( projectDir, "pom.xml" ) ) + MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File( + projectDir, + "pom.xml" ) ) .setShowErrors( true ) .setErrorReporter( reporter ) .setGoals( Arrays.asList( new String[] { @@ -551,15 +781,49 @@ public class ErrorReporterPointcutTest } public void testReportProjectCollision() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportProjectCollision( 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 testReportProjectValidationFailure() + throws URISyntaxException, IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + reporter.reportProjectValidationFailure( 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(); } } diff --git a/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj b/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj index 92f5dd1226..73c2166925 100644 --- a/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj +++ b/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj @@ -12,6 +12,7 @@ import org.apache.maven.model.Repository; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.MavenTools; +import org.apache.maven.project.build.model.DefaultModelLineageBuilder; import org.apache.maven.project.MavenProject; import org.apache.maven.project.DefaultMavenProjectBuilder; import org.apache.maven.project.InvalidProjectModelException; @@ -19,6 +20,7 @@ import org.apache.maven.project.ProjectBuildingException; import java.io.File; import java.util.Set; +import java.util.List; public privileged aspect PBEDerivativeReporterAspect extends AbstractProjectErrorReporterAspect @@ -34,6 +36,10 @@ public privileged aspect PBEDerivativeReporterAspect execution( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) ) && args( project, pomFile, .. ); + private pointcut within_pbldr_processProjectLogic( MavenProject project, File pomFile ): + withincode( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) ) + && args( project, pomFile, .. ); + private pointcut within_DefaultMavenProjectBuilder(): !withincode( * DefaultProfileAdvisor.*( .. ) ) && notWithinAspect(); @@ -63,8 +69,6 @@ public privileged aspect PBEDerivativeReporterAspect call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) ) && args( repo ); - private boolean processingPluginRepositories = false; - // ========================================================================= // Call Stack: // ========================================================================= @@ -82,31 +86,31 @@ public privileged aspect PBEDerivativeReporterAspect after( MavenProject project, File pomFile, Repository repo ) throwing( UnknownRepositoryLayoutException cause ): mavenTools_buildArtifactRepository( repo ) && cflow( pbldr_processProjectLogic( project, pomFile ) ) - && within_DefaultMavenProjectBuilder() { - getReporter().reportErrorCreatingArtifactRepository( project, pomFile, repo, cause, processingPluginRepositories ); + getReporter().reportErrorCreatingArtifactRepository( project.getId(), pomFile, repo, cause ); } - after(): - call( * Model+.getPluginRepositories() ) - && cflow( pbldr_processProjectLogic( MavenProject, File ) ) - && within_DefaultMavenProjectBuilder() - { - processingPluginRepositories = true; - } + private pointcut mlbldr_updateRepositorySet( Model model, File pomFile ): + execution( List DefaultModelLineageBuilder.updateRepositorySet( Model, *, File, .. ) ) + && args( model, *, pomFile, .. ); - after(): - call( * Model+.getRepositories() ) - && cflow( pbldr_processProjectLogic( MavenProject, File ) ) - && within_DefaultMavenProjectBuilder() + // ========================================================================= + // Call Stack: + // ========================================================================= + // ... + // --> DefaultModelLineageBuilder.buildModelLineage(..) + // --> DefaultModelLineageBuilder.resumeBuildingModelLineage(..) + // --> DefaultModelLineageBuilder.updateRepositorySet(..) (private) + // --> DefaultMavenTools.buildArtifactRepositories(..) + // --> DefaultMavenTools.buildArtifactRepository(..) + // <------ UnknownRepositoryLayoutException + // <------ ProjectBuildingException + // ========================================================================= + after( Model model, File pomFile, Repository repo ) throwing( UnknownRepositoryLayoutException cause ): + mavenTools_buildArtifactRepository( repo ) + && cflow( mlbldr_updateRepositorySet( model, pomFile ) ) { - processingPluginRepositories = false; - } - - after( MavenProject project, File pomFile ): - pbldr_processProjectLogic( project, pomFile ) - { - processingPluginRepositories = false; + getReporter().reportErrorCreatingArtifactRepository( model.getId(), pomFile, repo, cause ); } // ModelInterpolationException diff --git a/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj b/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj index 251b9e2478..751cbe9b44 100644 --- a/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj +++ b/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj @@ -72,7 +72,7 @@ public privileged aspect ProfileErrorReporterAspect throwing( ComponentLookupException cause ): applyActivatedProfiles_ComponentLookupException( model, pomFile, profile ) { - getReporter().reportActivatorLookupErrorWhileApplyingProfiles( model, pomFile, profile, cause ); + getReporter().reportActivatorLookupError( model.getId(), pomFile, profile, cause ); } protected pointcut profileActivatorCall( ProfileActivator activator ): @@ -107,7 +107,7 @@ public privileged aspect ProfileErrorReporterAspect throwing( ProfileActivationException cause ): applyActivatedProfiles_ActivatorThrown( activator, model, pomFile, profile, context ) { - getReporter().reportActivatorErrorWhileApplyingProfiles( activator, model, pomFile, profile, context, cause ); + getReporter().reportActivatorError( activator, model.getId(), pomFile, profile, context, cause ); } private pointcut pAdv_loadExternalProjectProfiles( Model model, File pomFile ): @@ -189,7 +189,7 @@ public privileged aspect ProfileErrorReporterAspect throwing( ComponentLookupException cause ): getArtifactRepositoriesFromActiveProfiles_ComponentLookupException( projectId, pomFile, profile ) { - getReporter().reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( projectId, pomFile, profile, cause ); + getReporter().reportActivatorLookupError( projectId, pomFile, profile, cause ); } private pointcut getArtifactRepositoriesFromActiveProfiles_ActivatorThrown( ProfileActivator activator, @@ -220,7 +220,7 @@ public privileged aspect ProfileErrorReporterAspect throwing( ProfileActivationException cause ): getArtifactRepositoriesFromActiveProfiles_ActivatorThrown( activator, projectId, pomFile, profile, context ) { - getReporter().reportActivatorErrorWhileGettingRepositoriesFromProfiles( activator, projectId, pomFile, profile, context, cause ); + getReporter().reportActivatorError( activator, projectId, pomFile, profile, context, cause ); } private pointcut getArtifactRepositoriesFromActiveProfiles_InvalidRepository( Repository repo, diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 5315d09e9f..b952106b6f 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -915,8 +915,15 @@ public class DefaultMavenProjectBuilder validateModel( model, pomFile ); - project.setRemoteArtifactRepositories( - mavenTools.buildArtifactRepositories( model.getRepositories() ) ); + try + { + project.setRemoteArtifactRepositories( + mavenTools.buildArtifactRepositories( model.getRepositories() ) ); + } + catch( Exception e ) + { + e.printStackTrace(); + } String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); diff --git a/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java b/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java index 3a02d8bd4b..e79ca0e474 100644 --- a/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java +++ b/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java @@ -114,51 +114,12 @@ public class DefaultProjectErrorReporter /** * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileApplyingProfiles(org.apache.maven.profiles.activation.ProfileActivator, org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException) */ - public void reportActivatorErrorWhileApplyingProfiles( ProfileActivator activator, - Model model, - File pomFile, - Profile profile, - ProfileActivationContext context, - ProfileActivationException cause ) - { - StringWriter writer = new StringWriter(); - - writer.write( NEWLINE ); - writer.write( "Profile activator: " ); - writer.write( activator.getClass().getName() ); - writer.write( " experienced an error while processing profile:" ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writer.write( profile.getId() ); - writer.write( " (source: " ); - writer.write( profile.getSource() ); - writer.write( ")" ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writer.write( "Error message: " ); - writer.write( NEWLINE ); - writer.write( cause.getMessage() ); - - addStandardInfo( model.getId(), pomFile, writer ); - addTips( ProjectErrorTips.getTipsForActivatorErrorWhileApplyingProfiles( activator, - model, - pomFile, - profile, - context, - cause ), writer ); - - registerBuildError( cause, writer.toString(), cause.getCause() ); - } - - /** - * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileGettingRepositoriesFromProfiles(org.apache.maven.profiles.activation.ProfileActivator, java.lang.String, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException) - */ - public void reportActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator, - String projectId, - File pomFile, - Profile profile, - ProfileActivationContext context, - ProfileActivationException cause ) + public void reportActivatorError( ProfileActivator activator, + String projectId, + File pomFile, + Profile profile, + ProfileActivationContext context, + ProfileActivationException cause ) { StringWriter writer = new StringWriter(); @@ -179,58 +140,23 @@ public class DefaultProjectErrorReporter writer.write( cause.getMessage() ); addStandardInfo( projectId, pomFile, writer ); - addTips( ProjectErrorTips.getTipsForActivatorErrorWhileGettingRepositoriesFromProfiles( activator, - projectId, - pomFile, - profile, - context, - cause ), - writer ); + addTips( ProjectErrorTips.getTipsForActivatorError( activator, + projectId, + pomFile, + profile, + context, + cause ), writer ); registerBuildError( cause, writer.toString(), cause.getCause() ); } /** - * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupErrorWhileApplyingProfiles(org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException) + * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupError(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException) */ - public void reportActivatorLookupErrorWhileApplyingProfiles( Model model, - File pomFile, - Profile profile, - ComponentLookupException cause ) - { - StringWriter writer = new StringWriter(); - - writer.write( NEWLINE ); - writer.write( "Error retrieving profile-activator component while processing profile:" ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writer.write( profile.getId() ); - writer.write( " (source: " ); - writer.write( profile.getSource() ); - writer.write( ")" ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writer.write( "Error message: " ); - writer.write( NEWLINE ); - writer.write( cause.getMessage() ); - - addStandardInfo( model.getId(), pomFile, writer ); - addTips( ProjectErrorTips.getTipsForActivatorLookupErrorWhileApplyingProfiles( model, - pomFile, - profile, - cause ), - writer ); - - registerBuildError( cause, writer.toString(), cause.getCause() ); - } - - /** - * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException) - */ - public void reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId, - File pomFile, - Profile profile, - ComponentLookupException cause ) + public void reportActivatorLookupError( String projectId, + File pomFile, + Profile profile, + ComponentLookupException cause ) { StringWriter writer = new StringWriter(); @@ -249,11 +175,10 @@ public class DefaultProjectErrorReporter writer.write( cause.getMessage() ); addStandardInfo( projectId, pomFile, writer ); - addTips( ProjectErrorTips.getTipsForActivatorLookupErrorWhileGettingRepositoriesFromProfiles( projectId, - pomFile, - profile, - cause ), - writer ); + addTips( ProjectErrorTips.getTipsForActivatorLookupError( projectId, + pomFile, + profile, + cause ), writer ); registerBuildError( cause, writer.toString(), cause.getCause() ); } @@ -385,11 +310,10 @@ public class DefaultProjectErrorReporter } } - public void reportErrorCreatingArtifactRepository( MavenProject project, + public void reportErrorCreatingArtifactRepository( String projectId, File pomFile, Repository repo, - UnknownRepositoryLayoutException cause, - boolean isPluginRepo ) + UnknownRepositoryLayoutException cause ) { StringWriter writer = new StringWriter(); @@ -405,8 +329,8 @@ public class DefaultProjectErrorReporter writer.write( cause.getMessage() ); writer.write( NEWLINE ); - addStandardInfo( project.getId(), pomFile, writer ); - addTips( ProjectErrorTips.getTipsForInvalidRepositorySpec( repo, project.getId(), pomFile, cause ), + addStandardInfo( projectId, pomFile, writer ); + addTips( ProjectErrorTips.getTipsForInvalidRepositorySpec( repo, projectId, pomFile, cause ), writer ); registerBuildError( cause, writer.toString() ); diff --git a/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java b/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java index ade8e8e2b8..95fb6f7f61 100644 --- a/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java +++ b/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java @@ -45,27 +45,6 @@ public interface ProjectErrorReporter * DefaultProfileAdvisor.applyActivatedProfiles(..) * DefaultProfileAdvisor.applyActivatedExternalProfiles(..) * --> DefaultProfileAdvisor.applyActivatedProfiles(..) (private) - * --> DefaultProfileManager.getActiveProfiles(..) - * --> DefaultProfileManager.isActive(..) (private) - * --> ProfileActivator.canDetermineActivation(..) - * --> ProfileActivator.isActive(..) - * <------ ProfileActivationException - * <------ ProjectBuildingException - * - */ - void reportActivatorErrorWhileApplyingProfiles( ProfileActivator activator, - Model model, - File pomFile, - Profile profile, - ProfileActivationContext context, - ProfileActivationException cause ); - - /** - * Call Stack: - *
- *
-     * DefaultProfileAdvisor.applyActivatedProfiles(..)
-     * DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
      * --> DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
      *     --> DefaultProfileManager.getActiveProfiles(..)
      *         --> DefaultProfileManager.isActive(..) (private)
@@ -75,12 +54,12 @@ public interface ProjectErrorReporter
      * <------ ProjectBuildingException
      * 
*/ - void reportActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator, - String projectId, - File pomFile, - Profile profile, - ProfileActivationContext context, - ProfileActivationException cause ); + void reportActivatorError( ProfileActivator activator, + String projectId, + File pomFile, + Profile profile, + ProfileActivationContext context, + ProfileActivationException cause ); /** * Call Stack: @@ -89,25 +68,6 @@ public interface ProjectErrorReporter * DefaultProfileAdvisor.applyActivatedProfiles(..) * DefaultProfileAdvisor.applyActivatedExternalProfiles(..) * --> DefaultProfileAdvisor.applyActivatedProfiles(..) (private) - * --> DefaultProfileManager.getActiveProfiles(..) - * --> DefaultProfileManager.isActive(..) (private) - * --> PlexusContainer.lookupList(..) - * <-- ComponentLookupException - * <-- ProfileActivationException - * <------ ProjectBuildingException - * - */ - void reportActivatorLookupErrorWhileApplyingProfiles( Model model, - File pomFile, - Profile profile, - ComponentLookupException cause ); - - /** - * Call Stack: - *
- *
-     * DefaultProfileAdvisor.applyActivatedProfiles(..)
-     * DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
      * --> DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
      *     --> DefaultProfileManager.getActiveProfiles(..)
      *         --> DefaultProfileManager.isActive(..) (private)
@@ -117,10 +77,10 @@ public interface ProjectErrorReporter
      * <------ ProjectBuildingException
      * 
*/ - void reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId, - File pomFile, - Profile profile, - ComponentLookupException cause ); + void reportActivatorLookupError( String projectId, + File pomFile, + Profile profile, + ComponentLookupException cause ); /** * Call Stack: @@ -211,11 +171,10 @@ public interface ProjectErrorReporter * <---------- ProjectBuildingException * */ - void reportErrorCreatingArtifactRepository( MavenProject project, + void reportErrorCreatingArtifactRepository( String projectId, File pomFile, Repository repo, - UnknownRepositoryLayoutException cause, - boolean isPluginRepo ); + UnknownRepositoryLayoutException cause ); /** * Call Stack: diff --git a/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java b/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java index 5bb22e4f38..4ea20237d6 100644 --- a/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java +++ b/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java @@ -33,12 +33,12 @@ public final class ProjectErrorTips { } - public static List getTipsForActivatorErrorWhileApplyingProfiles( ProfileActivator activator, - Model model, - File pomFile, - Profile profile, - ProfileActivationContext context, - ProfileActivationException cause ) + public static List getTipsForActivatorError( ProfileActivator activator, + String projectId, + File pomFile, + Profile profile, + ProfileActivationContext context, + ProfileActivationException cause ) { return listOf( new String[]{ "If this is a standard profile activator, see " + "http://maven.apache.org/pom.html#Activation for help configuring profile activation.", @@ -47,37 +47,10 @@ public final class ProjectErrorTips "XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } ); } - public static List getTipsForActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator, - String projectId, - File pomFile, - Profile profile, - ProfileActivationContext context, - ProfileActivationException cause ) - { - return listOf( new String[]{ "If this is a standard profile activator, see " - + "http://maven.apache.org/pom.html#Activation for help configuring profile activation.", - "XSD location for pom.xml: http://maven.apache.org/xsd/maven-4.0.0.xsd", - "XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd", - "XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } ); - } - - public static List getTipsForActivatorLookupErrorWhileApplyingProfiles( Model model, - File pomFile, - Profile profile, - ComponentLookupException cause ) - { - return listOf( new String[]{ "If this is a custom profile activator, please ensure the activator's " - + "artifact is present in the POM's build/extensions list.", - "See http://maven.apache.org/pom.html#Extensions for more on build extensions.", - "XSD location for pom.xml: http://maven.apache.org/xsd/maven-4.0.0.xsd", - "XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd", - "XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } ); - } - - public static List getTipsForActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId, - File pomFile, - Profile profile, - ComponentLookupException cause ) + public static List getTipsForActivatorLookupError( String projectId, + File pomFile, + Profile profile, + ComponentLookupException cause ) { return listOf( new String[]{ "If this is a custom profile activator, please ensure the activator's " + "artifact is present in the POM's build/extensions list.", diff --git a/pom.xml b/pom.xml index f2fcf6509a..140080bfab 100644 --- a/pom.xml +++ b/pom.xml @@ -227,6 +227,12 @@ under the License. 1.2_Java1.3 test
+ + commons-httpclient + commons-httpclient + 3.1 + test +