Closed dlaflamme closed 2 years ago
I'd love to know the answer to this, I'm facing the exact same issue.
I didn't see this until recently.
Most JVM libraries aren't really developed with a clear idea of compilation classpath and runtime classpath. Sometimes things you don't use directly still need to be on the compilation classpath because they appear on some APIs that the compiler needs.
This seems to be such a case.
So, you will need to add play-functional
or whatever the dependency is to your dependencies.yaml, that will make it a non-private dependency. And then you can depend on it without hacking the internal visibility of the file.
The motivation for separating the compile classpath from the runtime classpath is to improve the cache efficiency (you don't need to recompile if the compile classpath API jars didn't change and the source code didn't change even if the runtime classpath did change).
For my case, I found that with transitivity: runtimeDeps
set in my dependencies.yaml
, I had to list a lot of transitive dependencies out explicitly (and then require them in the deps of the target in question), which is probably the recommended path, but it made adding any new library a lot of work. I set transitivity: exports
and then I didn't need to list those transitive deps, though I suspect that's not good practice (even if it is convenient and allows me to avoid overspecifying the deps for my target). Is there a middle ground between "listing out every single transitive dependency in dependencies.yaml" and "using transitivity: exports (which is bad, I suppose?)"?
yeah, it's a tough call: how pedantic do we want to be and how minimal do we want to keep the class paths in order to minimize rebuilds.
Also, with rules_scala using strict deps, having jars on the class path you don't use can be an issue.
I have a simple scala file that has:
My dependencies.yaml file includes:
and the generated play BUILD file is:
Note that play_functional is a transitive dependency and thus has visibility as subpackages, presumably as a result of https://github.com/johnynek/bazel-deps/pull/165.
My BUILD file only lists play_json as a dependency:
bazel build fails with:
I can get this to build, but only if I add play_functional as a dependency in my BUILD file and I change the visibility of play_functional in the generated BUILD file (
3rdparty/jvm/com/typesafe/play/BUILD
) to public visibility. But doing this feels wrong. What is the correct way to deal with this?