gerrit/tools/bzl/classpath.bzl
Marco Miller 444d33286f Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Upgrade testcontainers to 1.12.1
  Bazel: Reuse version from .bazelversion for minimum used version check
  Bazel: Add fixes for --incompatible_disallow_legacy_java_provider
  Rename left over Buck prolog compiler class to Bazel

Change-Id: Ibe7b101a7c6e95a296ee8c2f01ad790d66c216d7
2019-09-10 21:02:33 +02:00

26 lines
756 B
Python

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