Skip to content

Forward-port #11985: remove redundant required MDO attrs + add extension coordinate validation (#11979)#12346

Merged
gnodet merged 2 commits into
masterfrom
fix-11979-master
Jun 25, 2026
Merged

Forward-port #11985: remove redundant required MDO attrs + add extension coordinate validation (#11979)#12346
gnodet merged 2 commits into
masterfrom
fix-11979-master

Conversation

@gnodet

@gnodet gnodet commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Forward-port of PR #11985 from maven-3.10.x to master, plus extension coordinate validation.

Changes

MDO annotation cleanup (forward-port of #11985)

Removes <required>true</required> from 13 fields in maven.mdo that were never validated and whose enforcement would break existing POMs. Updates Model.name description to document artifactId fallback.

Extension coordinate validation (new)

Adds WARNING-level validation for missing build.extensions.extension.groupId and build.extensions.extension.artifactId in DefaultModelValidator. These were the most actionable validation gaps identified in #11979.

Tests

  • Unit tests for extension coordinate validation (missing-extension-coordinates.xml)
  • Minimal POM validation tests (with/without parent)

Fixes #11979

…ion coordinate validation (#11979)

- Remove <required>true</required> from 13 metadata/defaulted fields in maven.mdo
  (forward-port of PR #11985 from maven-3.10.x)
- Update Model.name description to document artifactId fallback
- Add WARNING-level validation for missing extension groupId/artifactId
- Add unit tests for extension coordinate validation and minimal POM validation
@gnodet gnodet added the enhancement New feature or request label Jun 23, 2026
@gnodet gnodet added this to the 4.1.0 milestone Jun 23, 2026
@gnodet gnodet requested review from cstamas and mthmulders June 23, 2026 10:31
- Fix <name> field description in maven.mdo to not claim the model field
  defaults to artifactId (the fallback is a runtime behavior in
  MavenProject#getName(), not a model-level default)

Note: unlike the 4.0.x branch, the test POM resources minimal-with-parent.xml
and minimal-without-parent.xml are actually referenced by tests in
impl/maven-impl on master, so they are kept.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR forward-ports MDO “required” annotation cleanup to avoid misleading/generated requirements, and adds new validation to warn when build extensions omit essential coordinates.

Changes:

  • Removed redundant <required>true</required> annotations from several maven.mdo fields that are not enforced by validation (and could break existing POMs if enforced).
  • Added WARNING-level validation in DefaultModelValidator for missing build.extensions.extension.groupId and build.extensions.extension.artifactId.
  • Added/expanded validation test coverage, including minimal raw-model POMs (with/without parent) and a missing-extension-coordinates case.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
api/maven-api-model/src/main/mdo/maven.mdo Removes redundant required flags in the model metadata used for generated docs/XSD.
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java Adds extension coordinate checks (groupId/artifactId) emitting warnings.
impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelValidatorTest.java Adds unit test for missing extension coordinates plus minimal raw-model POM tests.
impl/maven-impl/src/test/resources/poms/validation/missing-extension-coordinates.xml New test POM missing extension groupId/artifactId to exercise new warnings.
impl/maven-impl/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml Minimal raw POM fixture validating parent-inheritance cases.
impl/maven-impl/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml Minimal raw POM fixture validating required coordinates when no parent exists.
compat/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java Adds minimal raw-model POM tests for compat validator coverage.
compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml Minimal raw POM fixture for compat test suite.
compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml Minimal raw POM fixture for compat test suite.
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java Removes an outdated TODO comment in getName().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<name>name</name>
<version>3.0.0+</version>
<required>true</required>
<description>The full name of the project.</description>
@gnodet gnodet merged commit 99a624d into master Jun 25, 2026
24 checks passed
@gnodet gnodet deleted the fix-11979-master branch June 25, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Required model fields vs validation

2 participants