Support root_module_optional_deps in module_ctx.extension_metadata #25046
Labels
team-ExternalDeps
External dependency handling, remote repositiories, WORKSPACE file.
type: feature request
untriaged
Description of the feature request:
As of today, module extensions can report what must be put into
use_repo
calls usingroot_module_direct_deps
androot_module_direct_dev_deps
with the help ofmodule_ctx.is_dev_dependency
, this is good in cases where all the repositories created by the module extension most likely will be used somewhere in the repo.However, repositories created by the module extension might be not be used at all and can be confusing to people and sometimes leads to spurious warning messages if omitted.
For instance, the rules_oci oci_pull extension creates several repositories and reports them with
root_module_direct_deps
. Given the examplethe extension reports the following repos,
distroless_base
,distroless_base_linux_amd64
,distroless_linux_arm64_v8
, heredistroless_base
and the other repos are interchangeable, while some users need the platform specific, other don't.Today, there is not much the extension do because it doesn't have a mechanism to determine if they were requested in the first place, so the extension has to assume they are going to be needed, and reports them with
root_module_direct_deps
.Feature request is to have another field in
extension_metadata
that extensions can report optional deps.Given module extension above, when users run
bazel mod tidy
, Bazel will create ause_repo
call withdistroless_base
entry and add the other two repositories if we are references anywhere in the dependency graph.Which category does this issue belong to?
External Dependency
What underlying problem are you trying to solve with this feature?
Reporting dependencies from module extension that are needed optionally.
See: #24950
See: bazel-contrib/rules_oci#727
See: bazel-contrib/rules_oci#611
See: https://github.com/bazel-contrib/rules_oci/pull/611/files#r1646582755 cc @fmeum
Which operating system are you running Bazel on?
darwin-arm64
What is the output of
bazel info release
?No response
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: