Currently, the groovy_library rule and those related to it, are not strict that users declare all direct dependencies. This is likely because of how it is computing transitive dependencies. Specifically the combination of depset and how it adding together the java target's transitive dependencies
def _groovy_jar_impl(ctx):
...
# Extract all transitive dependencies
# TODO(bazel-team): get transitive dependencies from other groovy libraries
all_deps = depset(ctx.files.deps)
for this_dep in ctx.attr.deps:
if hasattr(this_dep, "java"):
all_deps += this_dep.java.transitive_runtime_deps
This allows us to not necessarily list all of the java code we import. As some can be picked up transitively.
This goes against the grain of how Bazel traditionally operates, i.e. explicitly declare all directly used dependencies.
@laurentlb, as you know much more about Starlark, do you have any recommendations or thoughts on why the current implementation is sketchy. Kristina put a TODO statement three years ago, and the Starlark language has changed drastically since then.
Currently, the groovy_library rule and those related to it, are not strict that users declare all direct dependencies. This is likely because of how it is computing transitive dependencies. Specifically the combination of depset and how it adding together the java target's transitive dependencies
This allows us to not necessarily list all of the java code we import. As some can be picked up transitively.
This goes against the grain of how Bazel traditionally operates, i.e. explicitly declare all directly used dependencies.
@laurentlb, as you know much more about Starlark, do you have any recommendations or thoughts on why the current implementation is sketchy. Kristina put a TODO statement three years ago, and the Starlark language has changed drastically since then.
https://github.com/petroseskinder/rules_groovy/blob/master/groovy/groovy.bzl#L22