Files
gerrit/tools/bzl/classpath.bzl
David Ostrovsky 002c7931e2 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  js.bzl: Avoid using deprecated depset union
  gwt.bzl: Avoid using deprecated depset union
  classpath.bzl: Avoid using deprecated depset union
  javadoc.bzl: Avoid using deprecated depset union
  pkg_war.bzl: Avoid using deprecated depset union
  Update rules_closure to make it forward compatible

Change-Id: I1c74b3d65323d0866cc599f7c6bd50cfcf3553ee
2019-03-03 19:46:58 +01:00

26 lines
746 B
Python

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