gerrit/tools/bzl/classpath.bzl
David Pursehouse 1d53668145 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Bazel: Automatically fix lint errors with buildifier 0.20.0
  Bazel: Fix more buildifier warnings
  Bazel: Automatically fix lint errors with buildifier 0.20.0
  Fix typo in documentation of edit preferences
  Bazel: Automatically fix lint errors with buildifier

Change-Id: I3400928e4dca65264715dca3c29729237934f042
2019-01-10 21:44:13 +09:00

26 lines
716 B
Python

def _classpath_collector(ctx):
all = depset()
for d in ctx.attr.deps:
if hasattr(d, "java"):
all += d.java.transitive_runtime_deps
if hasattr(d.java.compilation_info, "runtime_classpath"):
all += d.java.compilation_info.runtime_classpath
elif hasattr(d, "files"):
all += d.files
as_strs = [c.path for c in 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,
)