Skip to content

Fix NPE in EnhancedPluginDescriptorBuilder with Maven 4#1094

Closed
gnodet wants to merge 1 commit intoapache:maven-plugin-tools-3.xfrom
gnodet:fix-enhanced-plugin-descriptor-builder-npe
Closed

Fix NPE in EnhancedPluginDescriptorBuilder with Maven 4#1094
gnodet wants to merge 1 commit intoapache:maven-plugin-tools-3.xfrom
gnodet:fix-enhanced-plugin-descriptor-builder-npe

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Mar 31, 2026

Summary

  • Fix NPE in EnhancedPluginDescriptorBuilder.build(Reader, String) when running under Maven 4
  • Maven 4 refactored PluginDescriptorBuilder.build() to no longer call buildConfiguration(), leaving the configuration field null
  • When configuration is null (Maven 4+), read requiredJavaVersion/requiredMavenVersion from the PluginDescriptor directly, since Maven 4's builder already populates them

Fixes #806

Context

This is the main blocker for #1091 (enable Maven 4 CI builds). Maven 4 changed PluginDescriptorBuilder.build(Reader, String) in MNG-8084 to delegate to a new build(ReaderSupplier, String) method that no longer calls the overridable buildConfiguration(). The EnhancedPluginDescriptorBuilder relied on that callback to capture the raw XML configuration.

Test plan

  • Existing unit tests pass (verified locally)
  • CI with Maven 3.9.14 should pass (no behavior change)
  • CI with Maven 4 should fix the 12 failing reporting ITs

🤖 Generated with Claude Code

Maven 4 refactored PluginDescriptorBuilder.build(Reader, String) to no
longer call buildConfiguration(), which EnhancedPluginDescriptorBuilder
overrides to capture the raw PlexusConfiguration. This caused a NPE when
accessing configuration.getChild() since the field was never set.

When running under Maven 4, the PluginDescriptorBuilder already populates
requiredJavaVersion and requiredMavenVersion directly on the PluginDescriptor,
so we can read them from there instead of from the raw configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet closed this Mar 31, 2026
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented Mar 31, 2026

Closing in favor of the proper fix in Maven itself: apache/maven#11869

The root cause is that PluginDescriptorBuilder.build(Reader, String) no longer calls the overridable buildConfiguration() method since the MNG-7947 refactoring. The Maven PR restores this callback in the deprecated methods.

Claude Code on behalf of Guillaume Nodet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant