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 a9014d5f87..9e8dfe05b8 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 @@ -123,7 +123,7 @@ public privileged aspect ExtensionErrorReporterAspect && call( ExtensionManagerException.new( .., ArtifactNotFoundException ) ) && args( .., cause ) { - getReporter().reportMissingArtifactWhileAddingExtensionPlugin( plugin, originModel, remoteRepos, request, cause ); + getReporter().reportExtensionPluginArtifactNotFound( plugin, originModel, remoteRepos, request, cause ); } before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionException 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 d7e0894ba7..e5845b59b0 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 @@ -4,6 +4,7 @@ import org.apache.maven.NoGoalsSpecifiedException; import org.apache.maven.ProjectCycleException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; @@ -26,7 +27,6 @@ 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; @@ -81,7 +81,7 @@ public interface CoreErrorReporter void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, ArtifactMetadataRetrievalException cause ); - void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause ); + void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, AbstractArtifactResolutionException cause ); void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause ); @@ -97,8 +97,6 @@ public interface CoreErrorReporter void reportLifecycleSpecErrorWhileValidatingTask( String task, MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause ); - 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 ); 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 db25f4508e..46679511c6 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 @@ -31,7 +31,6 @@ 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.PluginParameterExpressionEvaluator; import org.apache.maven.plugin.descriptor.Parameter; @@ -1170,34 +1169,6 @@ public class DefaultCoreErrorReporter writer.write( NEWLINE ); } - public void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, - Model originModel, - List remoteRepos, - MavenExecutionRequest request, - ArtifactNotFoundException cause ) - { - StringWriter writer = new StringWriter(); - - writer.write( NEWLINE ); - writer.write( "One or more dependency artifacts are missing for a plugin used by your project as a build extension." ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writer.write( "Project:" ); - writeProjectCoordinate( originModel, null, writer ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writer.write( "Plugin (used as an extension):" ); - writePluginInfo( plugin, writer ); - writer.write( NEWLINE ); - writer.write( NEWLINE ); - writeArtifactError( cause, writer ); - - addTips( CoreErrorTips.getErrorResolvingExtensionPluginArtifactsTips( plugin, originModel, cause ), - writer ); - - registerBuildError( cause, writer.toString(), cause.getCause() ); - } - public void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, @@ -1230,7 +1201,7 @@ public class DefaultCoreErrorReporter Model originModel, List remoteRepos, MavenExecutionRequest request, - PluginNotFoundException cause ) + AbstractArtifactResolutionException cause ) { StringWriter writer = new StringWriter(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java index 8735dea6ea..7a3aeceef6 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java @@ -276,6 +276,11 @@ public class DefaultPluginVersionManager version = artifactVersion; } + if ( version != null ) + { + getLogger().info( "Using version: " + version + " of plugin: " + groupId + ":" + artifactId ); + } + return version; } diff --git a/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginArtifactNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginArtifactNotFound-maven-plugin/1/testReportExtensionPluginArtifactNotFound-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginArtifactNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginArtifactNotFound-maven-plugin/1/testReportExtensionPluginArtifactNotFound-maven-plugin-1.pom new file mode 100644 index 0000000000..ad51210d2f --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginArtifactNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginArtifactNotFound-maven-plugin/1/testReportExtensionPluginArtifactNotFound-maven-plugin-1.pom @@ -0,0 +1,55 @@ + + + 4.0.0 + org.apache.maven.errortest + testReportExtensionPluginArtifactNotFound-maven-plugin + maven-plugin + 1 + + + + org.apache.maven + maven-plugin-api + 2.0 + + + nothing + nothing + 1 + + + + + + + maven-surefire-plugin + 2.3.1 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-resources-plugin + 2.2 + + + maven-jar-plugin + 2.1 + + + maven-compiler-plugin + 2.0.2 + + + maven-plugin-plugin + 2.3 + + + + + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginArtifactNotFound/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginArtifactNotFound/project/pom.xml new file mode 100644 index 0000000000..cc47bed268 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginArtifactNotFound/project/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + org.apache.maven + testReportExtensionPluginArtifactNotFound + 1 + + + + + org.apache.maven.errortest + testReportExtensionPluginArtifactNotFound-maven-plugin + 1 + true + + + + + diff --git a/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginVersionNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginVersionNotFound-maven-plugin/1/testReportExtensionPluginVersionNotFound-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginVersionNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginVersionNotFound-maven-plugin/1/testReportExtensionPluginVersionNotFound-maven-plugin-1.pom index f9fdf3a815..15b3d75779 100644 --- a/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginVersionNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginVersionNotFound-maven-plugin/1/testReportExtensionPluginVersionNotFound-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/testReportExtensionPluginVersionNotFound/local-repo/org/apache/maven/errortest/testReportExtensionPluginVersionNotFound-maven-plugin/1/testReportExtensionPluginVersionNotFound-maven-plugin-1.pom @@ -1,4 +1,5 @@ - + + 4.0.0 org.apache.maven.errortest testReportExtensionPluginVersionNotFound-maven-plugin @@ -9,7 +10,7 @@ org.apache.maven maven-plugin-api - 2.1-SNAPSHOT + 2.0 diff --git a/maven-embedder/src/test/error-reporting-projects/testReportIncompatibleMavenVersionForExtensionPlugin/local-repo/org/apache/maven/errortest/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin/1/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportIncompatibleMavenVersionForExtensionPlugin/local-repo/org/apache/maven/errortest/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin/1/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin-1.pom index 6d930464b6..a4a3788eb3 100644 --- a/maven-embedder/src/test/error-reporting-projects/testReportIncompatibleMavenVersionForExtensionPlugin/local-repo/org/apache/maven/errortest/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin/1/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/testReportIncompatibleMavenVersionForExtensionPlugin/local-repo/org/apache/maven/errortest/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin/1/testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin-1.pom @@ -1,4 +1,5 @@ - + + 4.0.0 org.apache.maven.errortest testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin @@ -13,7 +14,7 @@ org.apache.maven maven-plugin-api - 2.1-SNAPSHOT + 2.0 diff --git a/maven-embedder/src/test/error-reporting-projects/testReportInvalidDependencyVersionInExtensionPluginPOM/local-repo/org/apache/maven/errortest/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin/1/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportInvalidDependencyVersionInExtensionPluginPOM/local-repo/org/apache/maven/errortest/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin/1/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin-1.pom index 39d1c3e5e1..0d8112b49f 100644 --- a/maven-embedder/src/test/error-reporting-projects/testReportInvalidDependencyVersionInExtensionPluginPOM/local-repo/org/apache/maven/errortest/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin/1/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/testReportInvalidDependencyVersionInExtensionPluginPOM/local-repo/org/apache/maven/errortest/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin/1/testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin-1.pom @@ -1,4 +1,5 @@ - + + 4.0.0 org.apache.maven.errortest testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin @@ -9,7 +10,7 @@ org.apache.maven maven-plugin-api - 2.1-SNAPSHOT + 2.0 junit diff --git a/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom new file mode 100644 index 0000000000..e6dd7a2be6 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom @@ -0,0 +1,16 @@ + + + 4.0.0 + org.apache.maven.errortest + dep + 1 + pom + + + + junit + junit + [4.0,4.1] + + + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin/1/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin-1.jar b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin/1/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin-1.jar new file mode 100644 index 0000000000..edc812c0ad Binary files /dev/null and b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin/1/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin-1.jar differ diff --git a/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin/1/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin/1/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin-1.pom new file mode 100644 index 0000000000..f3584720c2 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/local-repo/org/apache/maven/errortest/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin/1/testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin-1.pom @@ -0,0 +1,60 @@ + + + 4.0.0 + org.apache.maven.errortest + testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin + maven-plugin + 1 + + + + org.apache.maven + maven-plugin-api + 2.0 + + + junit + junit + [3.8.1,3.8.2] + + + org.apache.maven.errortest + dep + 1 + + + + + + + maven-surefire-plugin + 2.3.1 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-resources-plugin + 2.2 + + + maven-jar-plugin + 2.1 + + + maven-compiler-plugin + 2.0.2 + + + maven-plugin-plugin + 2.3 + + + + + \ No newline at end of file diff --git a/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/project/pom.xml b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/project/pom.xml new file mode 100644 index 0000000000..d9c81f47c8 --- /dev/null +++ b/maven-embedder/src/test/error-reporting-projects/testReportUnresolvableArtifactWhileAddingExtensionPlugin/project/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + org.apache.maven.errortest + testReportUnresolvableArtifactWhileAddingExtensionPlugin + 1 + + + + + org.apache.maven.errortest + testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin + 1 + true + + + + + \ 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 3154c837f3..8992d4a38e 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 @@ -472,9 +472,29 @@ public class ErrorReporterPointcutTest } public void testReportExtensionPluginArtifactNotFound() + throws IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + File localRepo = new File( projectDir, "local-repo" ); + File project = new File( projectDir, "project" ); + reporter.reportExtensionPluginArtifactNotFound( null, null, null, null, null ); + reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER ); + reporterCtl.setVoidCallable(); + + reporterCtl.replay(); + + MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) + .setShowErrors( true ) + .setLocalRepositoryPath( localRepo ) + .setErrorReporter( reporter ) + .setGoals( Arrays.asList( new String[] { + "initialize" + } ) ); + + maven.execute( request ); + + reporterCtl.verify(); } public void testReportExtensionPluginVersionNotFound() @@ -659,12 +679,6 @@ public class ErrorReporterPointcutTest reporterCtl.verify(); } - public void testReportMissingArtifactWhileAddingExtensionPlugin() - { - // TODO Auto-generated method stub - - } - public void testReportMissingPluginDescriptor() { // TODO Auto-generated method stub @@ -872,9 +886,39 @@ public class ErrorReporterPointcutTest } public void testReportUnresolvableArtifactWhileAddingExtensionPlugin() + throws IOException { - // TODO Auto-generated method stub + File projectDir = prepareProjectDir(); + File localRepo = new File( projectDir, "local-repo" ); + File project = new File( projectDir, "project" ); + Settings settings = new Settings(); + settings.setOffline( true ); + settings.setLocalRepository( localRepo.getAbsolutePath() ); + + reporter.reportUnresolvableArtifactWhileAddingExtensionPlugin( null, null, null, null, null ); + reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER ); + reporterCtl.setVoidCallable(); + + reporterCtl.replay(); + + MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) + .setShowErrors( true ) + .setSettings( settings ) + .setErrorReporter( reporter ) +// .setErrorReporter( new DummyCoreErrorReporter() ) + .setGoals( Arrays.asList( new String[] { + "initialize" + } ) ); + + maven.execute( request ); +// MavenExecutionResult result = maven.execute( request ); +// if ( result.hasExceptions() ) +// { +// reportExceptions( result, project ); +// } + + reporterCtl.verify(); } public void testReportActivatorError()