Repository navigation
Conversation
Addresses bazel-contrib#1549. deduplicate_artifacts_with_root_priority() resolves a duplicate group:artifact between the root module and a contributing module by popping the non-root artifact and, when the root does not force its version, selecting the highest version. The selection was one-sided: when the non-root version won, it was appended to the result, but the losing root artifact was never removed, so both versions survived into the merged artifact list. Installs with duplicate_version_warning = "error" then fail early in _check_artifacts_are_unique(), before any conflict policy can act: Found duplicate artifact versions args4j:args4j has multiple versions 2.33, 2.37 The other two branches (root forces, or the root version is highest) already drop the popped non-root artifact, so only this branch could ship duplicates. Rebuild the returned list without root artifacts that lost the version comparison, so exactly one version per coordinate reaches the resolver regardless of which side won. The function loses its leading underscore so the new regression tests can load it.
Addresses bazel-contrib#1549. apply_root_version_conflict_policy() implements the documented semantics of version_conflict_policy = "pinned" -- user-specified versions are chosen unconditionally over transitive ones -- by treating root-declared artifacts as force_version = True during layered dependency merging. It was gated to the gradle and maven resolvers, leaving coursier, the default resolver, on the old behaviour: a contributing module's higher version outranks (or, with duplicate_version_warning = "error", collides with) the root module's deliberately pinned version. The gate is also internally inconsistent: under "pinned" the coursier code path already passes --force-version for every declared artifact at resolution time. Only the bzlmod merge layer ignored the policy, so the root-vs-contributor conflict was decided (or failed) before coursier's own pinned handling could run. Lift the gate: pinned now forces root-declared versions for every resolver. A root module application depending on libraries that contribute their own Maven dependencies via bzlmod layering (for example Gerrit with JGit contributing args4j) no longer needs to enumerate every overlapping coordinate with maven.amend_artifact(force_version = ...). Pinned coursier installs pick up force_version on their root artifacts, which changes lockfile input hashes; a one-time REPIN refreshes them. The two affected in-repo fixtures (policy_pinned_testing, coursier_resolved_with_boms) are repinned here, migrating them to the current lock format on the way; their resolved dependency versions are unchanged.
Author
|
Superseded by #1631. |
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.
…="pinned"
Addresses #1549.
When using rules_jvm_external with bzlmod module layering, multiple modules can contribute artifacts into the same maven.install repository via known_contributing_modules.
If both the root module and a contributing module declare the same group:artifact with different versions, the current merge logic may retain both versions unless the root explicitly sets force_version = True for each artifact (for example using maven.amend_artifact). This results in duplicate artifact entries in the merged artifact list and causes resolution to fail early with "Found duplicate artifact versions", even when the root module sets version_conflict_policy = "pinned".
However, the documented semantics of "pinned" are that user-specified versions should be chosen unconditionally over transitive ones.
This change aligns layered resolution with that expectation by treating all artifacts declared by the root module as if force_version = True when version_conflict_policy = "pinned" is used. This ensures that root-declared versions take precedence during layered dependency merging and prevents duplicate coordinates from reaching the resolver.
As a result, root modules can enforce their dependency versions across layered module contributions without needing to enumerate each artifact with maven.amend_artifact(force_version = ...).
This is particularly useful for applications acting as the root module that depend on libraries contributing their own Maven dependencies via bzlmod layering, and that require deterministic control over dependency versions across the combined dependency graph.