Files
gerrit/tools/bzl/classpath.bzl
David Ostrovsky af39827411 classpath.bzl: Avoid using deprecated depset union
Change-Id: I0ad36f82a2e6324e303205bccf8eaee2f3969952
2019-03-03 12:47:22 +01:00

25 lines
672 B
Python

def _classpath_collector(ctx):
all = []
for d in ctx.attr.deps:
if hasattr(d, "java"):
all.append(d.java.transitive_runtime_deps)
all.append(d.java.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,
)