Forward-port #11985: remove redundant required MDO attrs + add extension coordinate validation (#11979)#12346
Merged
Conversation
…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
- 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>
There was a problem hiding this comment.
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 severalmaven.mdofields that are not enforced by validation (and could break existing POMs if enforced). - Added WARNING-level validation in
DefaultModelValidatorfor missingbuild.extensions.extension.groupIdandbuild.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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inmaven.mdothat were never validated and whose enforcement would break existing POMs. UpdatesModel.namedescription to document artifactId fallback.Extension coordinate validation (new)
Adds WARNING-level validation for missing
build.extensions.extension.groupIdandbuild.extensions.extension.artifactIdinDefaultModelValidator. These were the most actionable validation gaps identified in #11979.Tests
Fixes #11979