bazelgazelle

How to find out why gazelle is adding a specific dependency?


We have proto files that import "google/api/annotations.proto";. I'm adding # gazelle:resolve proto go google/api/annotations.proto @org_golang_google_genproto//googleapis/api/annotations to some BUILD files but gazelle is still adding "@go_googleapis//google/api:annotations_go_proto" as a dep to go_library rules.

How do I find out why gazelle is doing that?


Solution

  • As per the docs for directives: https://github.com/bazelbuild/bazel-gazelle#directives

    import-lang is the language importing the library. This is usually the same as source-lang but may differ with generated code. For example, when resolving dependencies for a go_proto_library, source-lang would be "proto" and import-lang would be "go". import-lang may be omitted if it is the same as source-lang.

    Since you have your import-lang set to go, Its picking up the name of the rule defining the go_proto_library in the repo:

    https://github.com/googleapis/googleapis/blob/9f7c0ffdaa8ceb2f27982bad713a03306157a4d2/google/api/BUILD.bazel#L345