Provide a target substitution mechanism (e.g., in com/google/dagger let deps on :dagger dep on :dagger_api)
cgruber opened this issue · 0 comments
Given that we allow build segment rewriting per-artifact, to allow things like the dagger dep to carry an exported_plugin, but also because we are about to have automated dependency discovery from pom files, this leads to odd cases. For instance, where (say), our wrapped :dagger
target exports :dagger_plugin
as an exported_plugin, and that depends on :dagger_compiler
, the inferred deps list (from the pom) of :dagger_compiler
would naively depend on :dagger
. This creates a cycle. At present, we can verbosely just replace any build snippets that are affected, it becomes gross for something like dagger, where all the other :dagger-*
packages depend on the core :dagger
apis.
Having a mechanism to, for instance, say "for all of com/google/dagger/BUILD" any inferred deps on com.google.dagger:dagger should reference :dagger_api
instead of :dagger
we can specify these surgical changes more tersely.
I think it only makes sense to do these substitutions on a per-build-file basis, because it's really only to address these intra-BUILD situations, and we don't want ALL things to depend on :dagger_api
, because it's only the implementation details we need to swap. We created the :dagger
wrapper target precisely to enrich it, so we don't want to steer other consumers of dagger to the naive jar that doesn't have the exported_plugin.
So something like:
maven_repository_specification(
name = "maven",
artifacts = [ ... ],
build_substitutions = {
"com.google.dagger:dagger": DAGGER_TARGET_REPLACEMENT_SNIPPET,
},
target_substitutions = {
"com.google.dagger": { "dagger": "dagger_api" }
},
This means that, in the context of this group (and the package @maven/com/google/dagger and it's BUILD file) treat any dependency on dagger to be a dependency on dagger_api.