Skip to content

[Backport 4.0.x] Fix operator precedence skipping type=bom dependency imports - #12930

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12722-bom-import-fix
Aug 30, 2026
Merged

[Backport 4.0.x] Fix operator precedence skipping type=bom dependency imports#12930
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12722-bom-import-fix

Conversation

@gnodet

@gnodet gnodet commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of #12722 to maven-4.0.x.

importDependencyManagement skipped every dependency with type=bom because of operator precedence:

if (!(pom && import) || bom) {
    continue;
}

For type=bom the || bom term is always true, so BOM-typed entries never loaded managed dependencies. This fix treats (pom && import) || bom as an import BOM/POM entry.

Fixes #12589

* Fix operator precedence skipping type=bom dependency imports

importDependencyManagement treated BOM-typed import-scoped dependencies
as non-imports because `|| "bom".equals(...)` made the continue branch
always true for type=bom. Accept pom or bom with import scope, align
validator messaging, and cover with a regression test.

Fixes #12589

* type=bom does not require scope=import for dependency management import

The bom type inherently implies import semantics (unlike type=pom which
needs scope=import). Change the filter from (pom || bom) && import to
(pom && import) || bom, and update the test to verify that type=bom
alone is sufficient.

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

* Revert validator change: bom type does not require scope=import

The import-scope validator check fires only when scope=import is set.
Adding bom there incorrectly implies that type=bom requires scope=import,
but bom inherently implies import semantics and works without it.
The original check (type must be 'pom' for scope=import) is correct.

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

---------

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Aug 30, 2026
@gnodet gnodet added bug Something isn't working backport mvn4 labels Aug 30, 2026

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clean backport of #12722 to maven-4.0.x. The operator-precedence fix is correct — moving the closing parenthesis to group (pom && import) || bom inside the negation ensures type=bom entries are properly handled as import BOMs in Maven 4.

Observations (informational):

  • The 92 additions are justified: test POM (with ASF license header), test method, DI provider methods for file transport, imports, and the 2-line fix itself
  • The backport diff is identical to the merged #12722 on master (same 3 files, same changes)
  • The two earlier backport attempts (#12909, #12914) were superseded — the design discussion on #12914 confirmed that type=bom should not require scope=import since bom inherently implies import semantics in Maven 4
  • Maven 3.9.x and 3.10.x are not affected: those branches only check type=pom && scope=import with no type=bom handling, since bom is a Maven 4 concept

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

@gnodet
gnodet merged commit e3ee412 into maven-4.0.x Aug 30, 2026
24 checks passed
@gnodet
gnodet deleted the backport/12722-bom-import-fix branch August 30, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants