Skip to content

Require force_version for root module artifact to take precedence #1423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2025

Conversation

shs96c
Copy link
Collaborator

@shs96c shs96c commented Jul 21, 2025

There was concern expressed by some owners of sub-modules that deliberately contribute to the maven repo that the behaviour of implicitly overriding artifacts by merely listing them in the root module would lead to users accidentally overriding those values. Instead, require the root module to use force_version to override the specific coordinate, which is more inline with the original intention of force_version.

@shs96c shs96c requested review from jin and cheister as code owners July 21, 2025 10:50
@shs96c
Copy link
Collaborator Author

shs96c commented Jul 21, 2025

Note, this builds on #1422 so only the commits after "fix a thinko" need to be reviewed as part of this PR.

@@ -292,7 +301,7 @@ def _deduplicate_artifacts_with_root_priority(root_artifacts, non_root_artifacts
else:
warning_parts.append(maven_module)

print("WARNING: The following maven modules appear in multiple sub-modules with potentially different versions. " +
print("WARNING: The following coordinates from `%s` appear in multiple sub-modules with potentially different versions. " % name +
"Consider adding one of these to your root module to ensure consistent versions:\n\t%s" %
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this message be updated to tell people they'll need force_version=True for the coordinates in the root module?

@@ -18,6 +18,7 @@ maven.artifact(
exclusions = ["com.google.code.findbugs:jsr305"],
group = "com.google.guava",
version = "31.1-jre",
force_version = True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should force_version be in sorted order after exclusions?

@shs96c shs96c force-pushed the forced-versions branch from 051581c to 20fb415 Compare July 24, 2025 10:49
@shs96c shs96c merged commit 1bcdaea into bazel-contrib:master Jul 24, 2025
6 checks passed
@shs96c shs96c deleted the forced-versions branch July 24, 2025 11:59
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.

2 participants