bazelbuild / rules_groovy

Groovy rules for Bazel
Apache License 2.0
11 stars 29 forks source link

groovy_library should strict about declaring direct dependencies #20

Open petroseskinder opened 5 years ago

petroseskinder commented 5 years ago

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.

https://github.com/petroseskinder/rules_groovy/blob/master/groovy/groovy.bzl#L22

laurentlb commented 5 years ago

Sorry, I don't know.