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:36 UTC
(maven-plugin-tools) 02/02: Read the Maven 4 element names when the report parses plugin.xml
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 d58eb99473dafd3c6ac48cfd9344768e4cd495c2
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Sep 19 20:21:41 2026 +0200
Read the Maven 4 element names when the report parses plugin.xml
plugin-tools 4.x writes dependencyResolution, dependencyCollection,
directInvocationOnly, projectRequired and onlineRequired, but the
report's PluginDescriptorBuilder only knew the Maven 3 names, so the
goal page silently dropped those attributes for every plugin built with
4.x. Both spellings are accepted now.
---
.../src/it/plugin-report-400/verify.groovy | 3 +++
.../plugin/descriptor/PluginDescriptorBuilder.java | 24 +++++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
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 e8db3d53..a0f1c424 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
@@ -48,3 +48,6 @@ assert reportMojo.text.contains('<td>Report output directory.<br /><strong>Defau
// 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>.')
+// attributes carried by the Maven 4 element names of the descriptor
+assert noopMojo.text.contains('Executes by direct invocation only.')
+assert noopMojo.text.contains('Requires that Maven runs in online mode.')
diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java
index d5e2c722..9d7b288b 100644
--- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java
+++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java
@@ -188,25 +188,25 @@ public class PluginDescriptorBuilder {
mojo.setDescription(c.getChild("description").getValue());
- PlexusConfiguration dependencyResolution = c.getChild("requiresDependencyResolution", false);
+ String dependencyResolution = childValue(c, "dependencyResolution", "requiresDependencyResolution");
if (dependencyResolution != null) {
- mojo.setDependencyResolutionRequired(dependencyResolution.getValue());
+ mojo.setDependencyResolutionRequired(dependencyResolution);
}
- PlexusConfiguration dependencyCollection = c.getChild("requiresDependencyCollection", false);
+ String dependencyCollection = childValue(c, "dependencyCollection", "requiresDependencyCollection");
if (dependencyCollection != null) {
- mojo.setDependencyCollectionRequired(dependencyCollection.getValue());
+ mojo.setDependencyCollectionRequired(dependencyCollection);
}
- String directInvocationOnly = c.getChild("requiresDirectInvocation").getValue();
+ String directInvocationOnly = childValue(c, "directInvocationOnly", "requiresDirectInvocation");
if (directInvocationOnly != null) {
mojo.setDirectInvocationOnly(Boolean.parseBoolean(directInvocationOnly));
}
- String requiresProject = c.getChild("requiresProject").getValue();
+ String requiresProject = childValue(c, "projectRequired", "requiresProject");
if (requiresProject != null) {
mojo.setProjectRequired(Boolean.parseBoolean(requiresProject));
@@ -224,7 +224,7 @@ public class PluginDescriptorBuilder {
mojo.setAggregator(Boolean.parseBoolean(aggregator));
}
- String requiresOnline = c.getChild("requiresOnline").getValue();
+ String requiresOnline = childValue(c, "onlineRequired", "requiresOnline");
if (requiresOnline != null) {
mojo.setOnlineRequired(Boolean.parseBoolean(requiresOnline));
@@ -337,4 +337,14 @@ public class PluginDescriptorBuilder {
throw new PlexusConfigurationException(e.getMessage(), e);
}
}
+ /**
+ * Descriptors written by plugin-tools 4.x use the Maven 4 element names, older ones the Maven 3 names.
+ */
+ private static String childValue(PlexusConfiguration c, String v4Name, String v3Name) {
+ PlexusConfiguration child = c.getChild(v4Name, false);
+ if (child == null) {
+ child = c.getChild(v3Name, false);
+ }
+ return child != null ? child.getValue() : null;
+ }
}