add dep commands don't work for java_proto_library
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description
The suggested fix for Strict Java Deps errors adds the wrong target for dependencies on `java_proto_library`s. 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
```
Contributor guide
Research direction
Start with the linked gist and reproduce the failure using `bazel build :b` at release 0.11.1. Trace the Strict Java Deps diagnostic and its suggested buildozer command, then verify that the dependency suggestion targets `//:p_java_proto` rather than `//:p_proto` and that the subsequent build succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100