Skip to content

add dep commands don't work for java_proto_libraryΒ #4990

@cushon

Description

@cushon

Description

The suggested fix for Strict Java Deps errors adds the wrong target for dependencies on java_proto_librarys. It suggests adding a dep on the underlying proto_library target, instead of on the java_proto_library target.

Repro

First, download: https://gist.github.com/cushon/0241dafdb608b7e2f37c475d3304aa18

Building fails with a strict deps error:

$ bazel build :b
...
B.java:2: error: [strict] Using type com.test.proto.P from an indirect dependency (TOOL_INFO: "//:p_proto wrapped in java_proto_library"). See command below **
  com.test.proto.P.Message m;
                ^
 ** Please add the following dependencies: 
  //:p_proto  to //:b 
 ** You can use the following buildozer command: 
buildozer 'add deps //:p_proto ' //:b 

The suggested fix is to add //p:proto, which does not fix the problem:

$ buildozer 'add deps //:p_proto ' //:b 
fixed ./sjdproto/BUILD
$ bazel build :b
B.java:2: error: [strict] Using type com.test.proto.P from an indirect dependency (TOOL_INFO: "//:p_proto wrapped in java_proto_library"). See command below **
  com.test.proto.P.Message m;

The correct dep to add is //:p_java_proto:

$ buildozer 'add deps //:p_java_proto ' //:b 
$ bazel build :b
...
INFO: Build completed successfully

What's the output of bazel info release?

$ bazel info release
release 0.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-JavaIssues for Java rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions