bazel: strict deps labels are incorrect when using non java_* rules

Description of the problem / feature request:

Strict deps labels are incorrect when using scala_import I suspect the problem is in the java rules and not scala_import since java_rules seems to perform their own heuristics which breaks if a different “actor” is in play and scala_import here is accidental. I might be incorrect in my analysis but a few months ago when I debugged it this is what I saw (don’t have links to bazel code now, sorry 😦 )

Feature requests: what underlying problem are you trying to solve with this feature?

Trying to use java_library or java_common.compile with strict deps warnings

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

clone https://github.com/ittaiz/bazel-strict-deps-labels-issue run bazel build --strict_java_deps=error //... see:

TransitiveUser.java:1: error: [strict] Using type com.google.common.cache.Cache from an indirect dependency (TOOL_INFO: "@com_google_guava_guava//jar:guava-19.0.jar"). See command below **
import com.google.common.cache.Cache;
                              ^
 ** Please add the following dependencies:
  @com_google_guava_guava//jar:guava-19.0.jar  to //:transitive_user
 ** You can use the following buildozer command:
buildozer 'add deps @com_google_guava_guava//jar:guava-19.0.jar ' //:transitive_user

INFO: Elapsed time: 0.279s, Critical Path: 0.14s
FAILED: Build did NOT complete successfully

expected at the very least @com_google_guava_guava//jar and actually I’d like it to be //:import since the rule effectively exports that file

What operating system are you running Bazel on?

os x

What’s the output of bazel info release?

release 0.8.1-homebrew

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 43 (34 by maintainers)

Most upvoted comments

ok continuing the design discussion that started in #4846 about an “API” for strict-deps labels passing between JVM rules. There are currently 3 options as far as I can tell:

  1. Pass a Map of Labels->Jar Paths in the providers. 1.1 Pro- Allows redefining label ownership post jar creation for example for exports, Easy to integrate via JavaInfo and can be pretty seamless via JavaInfo collecting the labels itself . 1.2 Con- not sure, @tomlu ?
  2. Pass a Map of Labels->Jar Paths in the command line. Not actually sure what’s the use-case for it but @tomlu mentioned it so I thought I should add it here.
  3. Bake the label into each jar (as a manifest attribute) and have each tool read it if it needs the label. 3.1 Pro- localizes the label “tagging” and is immune to intermediate rules not passing the providers (can this issue happen? not sure) 3.2 Con- A jar has exactly one label and can’t be redefined (again exports). Also needs to be reimplemented by tools creating jars if they circumvent ijar.

I think I’m missing some context on the con of providers and I also think we need to hash out the exports use-case since that feels to be the bone of contention here