diff --git a/pom.xml b/pom.xml
index a1c9c3be..944362f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,15 +131,11 @@
org.apache.maven.reporting
maven-reporting-api
3.1.1
-
-
- org.apache.maven.reporting
- maven-reporting-exec
- 1.6.0
+
- org.apache.maven
- maven-settings-builder
+ *
+ *
diff --git a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
index 516961e2..dc3cbe3e 100644
--- a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
@@ -38,6 +38,7 @@
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MavenPluginManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -54,7 +55,6 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.reporting.MavenReport;
-import org.apache.maven.reporting.exec.MavenPluginManagerHelper;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.tools.plugin.generator.GeneratorUtils;
import org.apache.maven.tools.plugin.util.PluginUtils;
@@ -100,7 +100,7 @@ public class DescribeMojo extends AbstractHelpMojo {
* Component used to get a plugin descriptor from a given plugin.
*/
@Component
- private MavenPluginManagerHelper pluginManager;
+ protected MavenPluginManager pluginManager;
/**
* Component used to get a plugin by its prefix and get mojo descriptors.
@@ -310,7 +310,8 @@ private PluginDescriptor lookupPluginDescriptor(PluginInfo pi) throws MojoExecut
}
try {
- return pluginManager.getPluginDescriptor(forLookup, session);
+ return pluginManager.getPluginDescriptor(
+ forLookup, project.getRemotePluginRepositories(), session.getRepositorySession());
} catch (Exception e) {
throw new MojoExecutionException(
"Error retrieving plugin descriptor for:" + LS + LS + "groupId: '"
diff --git a/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java b/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
index 0d2c140a..ce210f18 100644
--- a/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
@@ -19,10 +19,12 @@
package org.apache.maven.plugins.help;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.internal.MojoDescriptorCreator;
import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.MavenPluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -31,7 +33,7 @@
import org.apache.maven.plugin.version.PluginVersionResult;
import org.apache.maven.plugins.help.DescribeMojo.PluginInfo;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.exec.MavenPluginManagerHelper;
+import org.eclipse.aether.RepositorySystemSession;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -196,14 +198,19 @@ public void testLookupPluginDescriptorPrefixWithVersion() throws Throwable {
MojoDescriptorCreator mojoDescriptorCreator = mock(MojoDescriptorCreator.class);
PluginVersionResolver pluginVersionResolver = mock(PluginVersionResolver.class);
- MavenPluginManagerHelper pluginManager = mock(MavenPluginManagerHelper.class);
+ MavenPluginManager pluginManager = mock(MavenPluginManager.class);
MavenSession session = mock(MavenSession.class);
+ when(session.getRepositorySession()).thenReturn(mock(RepositorySystemSession.class));
writeDeclaredField(mojo, "mojoDescriptorCreator", mojoDescriptorCreator, true);
writeDeclaredField(mojo, "pluginVersionResolver", pluginVersionResolver, true);
writeDeclaredField(mojo, "pluginManager", pluginManager, true);
writeField(mojo, "session", session, true);
+ MavenProject mavenProject = new MavenProject();
+ mavenProject.setPluginArtifactRepositories(Collections.emptyList());
+ writeField(mojo, "project", mavenProject, true);
when(mojoDescriptorCreator.findPluginForPrefix("help", session)).thenReturn(plugin);
- when(pluginManager.getPluginDescriptor(any(Plugin.class), eq(session))).thenReturn(pd);
+ when(pluginManager.getPluginDescriptor(any(Plugin.class), anyList(), any()))
+ .thenReturn(pd);
PluginDescriptor returned = (PluginDescriptor) invokeMethod(mojo, true, "lookupPluginDescriptor", pi);
@@ -212,7 +219,7 @@ public void testLookupPluginDescriptorPrefixWithVersion() throws Throwable {
verify(mojoDescriptorCreator).findPluginForPrefix("help", session);
verify(pluginVersionResolver, never()).resolve(any(PluginVersionRequest.class));
ArgumentCaptor argument = ArgumentCaptor.forClass(Plugin.class);
- verify(pluginManager).getPluginDescriptor(argument.capture(), eq(session));
+ verify(pluginManager).getPluginDescriptor(argument.capture(), anyList(), any());
Plugin capturedPlugin = argument.getValue();
assertEquals("org.test", capturedPlugin.getGroupId());
assertEquals("test", capturedPlugin.getArtifactId());
@@ -234,18 +241,22 @@ public void testLookupPluginDescriptorPrefixWithoutVersion() throws Throwable {
MojoDescriptorCreator mojoDescriptorCreator = mock(MojoDescriptorCreator.class);
PluginVersionResolver pluginVersionResolver = mock(PluginVersionResolver.class);
- MavenPluginManagerHelper pluginManager = mock(MavenPluginManagerHelper.class);
+ MavenPluginManager pluginManager = mock(MavenPluginManager.class);
PluginVersionResult versionResult = mock(PluginVersionResult.class);
MavenSession session = mock(MavenSession.class);
+ when(session.getRepositorySession()).thenReturn(mock(RepositorySystemSession.class));
writeDeclaredField(mojo, "mojoDescriptorCreator", mojoDescriptorCreator, true);
writeDeclaredField(mojo, "pluginVersionResolver", pluginVersionResolver, true);
writeDeclaredField(mojo, "pluginManager", pluginManager, true);
writeField(mojo, "session", session, true);
- writeField(mojo, "project", new MavenProject(), true);
+ MavenProject mavenProject = new MavenProject();
+ mavenProject.setPluginArtifactRepositories(Collections.emptyList());
+ writeField(mojo, "project", mavenProject, true);
when(mojoDescriptorCreator.findPluginForPrefix("help", session)).thenReturn(plugin);
when(pluginVersionResolver.resolve(any(PluginVersionRequest.class))).thenReturn(versionResult);
when(versionResult.getVersion()).thenReturn("1.0");
- when(pluginManager.getPluginDescriptor(any(Plugin.class), eq(session))).thenReturn(pd);
+ when(pluginManager.getPluginDescriptor(any(Plugin.class), anyList(), any()))
+ .thenReturn(pd);
PluginDescriptor returned = (PluginDescriptor) invokeMethod(mojo, true, "lookupPluginDescriptor", pi);
assertEquals(pd, returned);
@@ -256,7 +267,7 @@ public void testLookupPluginDescriptorPrefixWithoutVersion() throws Throwable {
assertEquals("org.test", versionArgument.getValue().getGroupId());
assertEquals("test", versionArgument.getValue().getArtifactId());
ArgumentCaptor argument = ArgumentCaptor.forClass(Plugin.class);
- verify(pluginManager).getPluginDescriptor(argument.capture(), eq(session));
+ verify(pluginManager).getPluginDescriptor(argument.capture(), anyList(), any());
Plugin capturedPlugin = argument.getValue();
assertEquals("org.test", capturedPlugin.getGroupId());
assertEquals("test", capturedPlugin.getArtifactId());
@@ -276,13 +287,18 @@ public void testLookupPluginDescriptorGAV() throws Throwable {
MojoDescriptorCreator mojoDescriptorCreator = mock(MojoDescriptorCreator.class);
PluginVersionResolver pluginVersionResolver = mock(PluginVersionResolver.class);
- MavenPluginManagerHelper pluginManager = mock(MavenPluginManagerHelper.class);
+ MavenPluginManager pluginManager = mock(MavenPluginManager.class);
MavenSession session = mock(MavenSession.class);
+ when(session.getRepositorySession()).thenReturn(mock(RepositorySystemSession.class));
writeDeclaredField(mojo, "mojoDescriptorCreator", mojoDescriptorCreator, true);
writeDeclaredField(mojo, "pluginVersionResolver", pluginVersionResolver, true);
writeDeclaredField(mojo, "pluginManager", pluginManager, true);
writeField(mojo, "session", session, true);
- when(pluginManager.getPluginDescriptor(any(Plugin.class), eq(session))).thenReturn(pd);
+ MavenProject mavenProject = new MavenProject();
+ mavenProject.setPluginArtifactRepositories(Collections.emptyList());
+ writeField(mojo, "project", mavenProject, true);
+ when(pluginManager.getPluginDescriptor(any(Plugin.class), anyList(), any()))
+ .thenReturn(pd);
PluginDescriptor returned = (PluginDescriptor) invokeMethod(mojo, true, "lookupPluginDescriptor", pi);
@@ -291,7 +307,7 @@ public void testLookupPluginDescriptorGAV() throws Throwable {
verify(mojoDescriptorCreator, never()).findPluginForPrefix(any(String.class), any(MavenSession.class));
verify(pluginVersionResolver, never()).resolve(any(PluginVersionRequest.class));
ArgumentCaptor argument = ArgumentCaptor.forClass(Plugin.class);
- verify(pluginManager).getPluginDescriptor(argument.capture(), eq(session));
+ verify(pluginManager).getPluginDescriptor(argument.capture(), anyList(), any());
Plugin capturedPlugin = argument.getValue();
assertEquals("org.test", capturedPlugin.getGroupId());
assertEquals("test", capturedPlugin.getArtifactId());