Skip to content

[4.0.x] [GH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions#12236

Merged
gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:cherry-pick-11780-to-4.0.x
Jun 4, 2026
Merged

[4.0.x] [GH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions#12236
gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:cherry-pick-11780-to-4.0.x

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Jun 4, 2026

Cherry-pick of #11780

Adaptation for 4.0.x:

  • Removed deployBuildPom() method (constant not yet on 4.0.x)
  • Added missing MavenException import
  • Added super("[4.0.0-rc-1,)") constructor to IT test

…l versions (apache#11780)

* [apacheGH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions

When a POM-packaged project (parent POM) uses Maven 4.1.0 features
like profile conditions that cannot be stripped during consumer POM
transformation, the build now fails fast with actionable guidance
instead of silently deploying a consumer POM that Maven 3 and Gradle
cannot resolve.

The validation applies only to:
- POM-packaged projects (parent POMs) on the non-flatten path
- Projects without preserve.model.version=true

Also adds a maven.consumer.pom.removeUnusedManagedDependencies property
(default: true) to control whether unused managed dependencies are
removed during consumer POM flattening.

* Refactor consumer POM validation error message to use text blocks

Convert string concatenation in the consumer POM model version validation
error message to use Java text blocks for improved readability and
maintainability. The multi-line error message is now expressed as a
text block with .formatted() for parameter substitution.

This change affects the validation that ensures POM-packaged projects
can be downgraded to model version 4.0.0 for Maven 3/Gradle compatibility.

* Fix Spotless formatting violation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <claude@anthropic.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@gnodet gnodet merged commit f927773 into apache:maven-4.0.x Jun 4, 2026
@github-actions github-actions Bot added this to the 4.0.0-rc-6 milestone Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

@gnodet Please assign appropriate label to PR according to the type of change.

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