Community build: automatic dependency overrides #11504
Merged
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.
A follow up to #10503.
This PR adds automatic dependency override handling to the community build using an sbt plugin.
The implementation is deliberately simple, and works thusly:
The
sbt-community-build
plugin is injected into each community build project.The plugin hooks into the
publishLocal
task and for every published module, appends a ModuleID serialization to a tracking file.The entries in the tracking file are injected as
dependencyOverrides
in build scope in subsequent community build projects.Notes:
A fresh dependency tracking file is created for each run of the community build.
It was considered to apply the dependency overrides selectively at project scope.
This was not done in this PR for two reasons:
It adds considerable complexity.
I ran into difficulty writing an implementation that would pass the
inter-project-transitive-dep
test, and have not had time to explore further.Limitations:
Since the dependency overrides are applied en masse in build scope rather than selectively in project scope, a difficulty arises for any dependency which is published with the same organization and name but differing version, as is the case for cats-effect-2 and cats-effect-3.
This means that if some projects in the community build depend on cats-effect-2, and others depend on cats-effect-3 (causing both to be published), the automatic dependency overrides would fail for one set or the other;
sbt
seems to treat duplicate-keyed dependency overrides as last one wins.Some projects may in fact depend on both, e.g.
munit-cats-effect
(not currently in the community build) is a multi-project build where one of its sub-projects depends on cats-effect-2 and another depends on cats-effect-3. Such a project can be handled by layering manual overrides atop the automatic dependency overrides.Currently, no projects in the community build depend on cats-effect.
This limitation could be overcome by an implementation injecting project-scoped dependency overrides coupled with a heuristic to determine which version should be selected in the case of duplicate artifact ids.
Nevertheless I think this PR is useful in its current state.