Fix operator precedence skipping type=bom dependency imports - #12722
Fix operator precedence skipping type=bom dependency imports#12722kalayciburak wants to merge 1 commit into
Conversation
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 apache#12589
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-scoped bug fix for operator precedence in importDependencyManagement that silently skipped type=bom dependencies. The fix is logically correct, the regression test adequately covers the scenario, and the validator update is consistent.
Non-blocking observations:
-
Validator assertion drift (low): The existing
testBadImportScopeTypeassertion checks for substring"must be 'pom'"which still passes against the new message"must be 'pom' or 'bom'..."but doesn't verify the updated text. Consider updating the assertion to match the new full message. -
Pre-existing cycle message (low): The cycle detection message says "The dependencies of type=pom and with scope=import form a cycle" — now that
type=bomis also processed, this could be misleading for bom-typed cycles. Not introduced by this PR. -
Nice design choice: The PR's expression
!((pom || bom) && import)is semantically cleaner than the alternative!(pom && import) && !bomsuggested in the issue — the latter would have incorrectly allowedtype=bomentries withoutscope=importto pass through the filter.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-scoped bug fix for operator precedence in importDependencyManagement that silently skipped type=bom import-scoped dependencies. The logic fix is verified correct, the regression test adequately covers the scenario, and the validator update is consistent.
Minor observations (non-blocking):
- The existing
testBadImportScopeTypeassertion checks for substring"must be 'pom'"which still passes against the new message viaassertContains(substring match), so it does not actually verify the updated validator text. Consider updating the assertion to"must be 'pom' or 'bom'"to confirm the new wording. Not a blocker since no code in this PR touches that test. - The cycle detection message says "The dependencies of type=pom and with scope=import form a cycle" — now that
type=bomis also processed, this message could be misleading for bom-typed cycles. Pre-existing issue, not introduced by this PR. - The fix's expression
!("pom" || "bom") && "import")is semantically cleaner and more correct than the alternative suggested in the issue. - The compat layer (
compat/maven-model-builder) has a similar import check that only handlestype=pom, which is expected sincetype=bomis a Maven 4 concept.
This review was generated by an AI agent (Claude Code) and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Summary
importDependencyManagementskipped every dependency withtype=bombecause of operator precedence:For
type=bomthe|| bomterm is always true, so BOM-typed import-scoped entries never load managed dependencies. Maven 4 definesType.BOM(mapped to thepomextension), so these imports should be processed the same way astype=pom+scope=import.This change:
(pom || bom) && importas an import BOM/POM entrytype=bomin the import-scope validator message (warning only for other types)type=bomFixes #12589
Checklist
mvn verifyto make sure basic checks pass.Test plan
Executed:
Result: 98 tests, 0 failures (includes new
testImportScopeBomTypeIsProcessed).