Files
gerrit/tools/bzl/classpath.bzl
David Ostrovsky 09c905ef16 Bazel: Add fixes for --incompatible_disallow_legacy_java_provider
In some places the old style, string-indexed Starlark ‘java’ provider
was already replaced with new style javaInfo in: I1d5afb8b022. But some
other places were missed to be replaced.

Change-Id: Ie5ee9eed689793f532f99aeaa38f12ec87a709e1
2019-09-10 09:05:18 +09:00

25 lines
677 B
Python

def _classpath_collector(ctx):
all = []
for d in ctx.attr.deps:
if JavaInfo in d:
all.append(d[JavaInfo].transitive_runtime_deps)
all.append(d[JavaInfo].compilation_info.runtime_classpath)
elif hasattr(d, "files"):
all.append(d.files)
as_strs = [c.path for c in depset(transitive = all).to_list()]
ctx.actions.write(
output = ctx.outputs.runtime,
content = "\n".join(sorted(as_strs)),
)
classpath_collector = rule(
attrs = {
"deps": attr.label_list(),
},
outputs = {
"runtime": "%{name}.runtime_classpath",
},
implementation = _classpath_collector,
)