You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/09/19 21:38:35 UTC

(maven-plugin-tools) 01/02: [MPLUGIN-515] Render requiresDependencyCollection in the goal report

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 1c207fe67038a1517feed0e25e630b9b392d2a35
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Sep 19 12:21:19 2026 +0200

    [MPLUGIN-515] Render requiresDependencyCollection in the goal report
    
    GoalRenderer only rendered the attribute for an ExtendedMojoDescriptor,
    but the report reads descriptors back from plugin.xml as plain
    MojoDescriptors, so the branch never ran. The value is on MojoDescriptor
    itself since maven-plugin-api 3.x.
    
    (cherry picked from commit ab0e616e72d6c424dee763f8d811ccdac6ac3244)
---
 .../src/it/plugin-report-400/src/main/java/org/MyMojo.java        | 1 +
 maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy | 3 +++
 .../java/org/apache/maven/plugin/plugin/report/GoalRenderer.java  | 8 +-------
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java b/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java
index d2f2e77f..6b7b3030 100644
--- a/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java
@@ -35,6 +35,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
         name = "noop",
         defaultPhase = LifecyclePhase.PROCESS_SOURCES,
         requiresDependencyResolution = ResolutionScope.TEST,
+        requiresDependencyCollection = ResolutionScope.COMPILE,
         requiresDirectInvocation = true,
         requiresOnline = true,
         inheritByDefault = false,
diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy
index 18fbfbbd..e8db3d53 100644
--- a/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy
@@ -45,3 +45,6 @@ assert reportMojo.isFile()
 
 assert reportMojo.text.contains('<td>Report output directory.<br /><strong>Default</strong>: <code>${project.build.directory}/generated-site/xdoc</code></td>')
 
+// MPLUGIN-515: both dependency scopes are rendered as goal attributes
+assert noopMojo.text.contains('Requires dependency resolution of artifacts in scope: <code>test</code>.')
+assert noopMojo.text.contains('Requires dependency collection of artifacts in scope: <code>compile</code>.')
diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java
index 20d2ea45..e73f55fa 100644
--- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java
+++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java
@@ -43,7 +43,6 @@ import org.apache.maven.plugin.descriptor.Parameter;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
-import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
 import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
 import org.apache.maven.tools.plugin.util.PluginUtils;
 import org.codehaus.plexus.i18n.I18N;
@@ -170,12 +169,7 @@ public class GoalRenderer extends AbstractPluginReportRenderer {
         renderAttribute(descriptor.isAggregator(), "aggregator");
         renderAttribute(descriptor.isDirectInvocationOnly(), "directInvocationOnly");
         renderAttribute(descriptor.isDependencyResolutionRequired(), "dependencyResolutionRequired");
-
-        if (descriptor instanceof ExtendedMojoDescriptor) {
-            ExtendedMojoDescriptor extendedDescriptor = (ExtendedMojoDescriptor) descriptor;
-            renderAttribute(extendedDescriptor.getDependencyCollectionRequired(), "dependencyCollectionRequired");
-        }
-
+        renderAttribute(descriptor.getDependencyCollectionRequired(), "dependencyCollectionRequired");
         renderAttribute(descriptor.isThreadSafe(), "threadSafe");
         renderAttribute(!descriptor.isThreadSafe(), "notThreadSafe");
         renderAttribute(descriptor.getSince(), "since");