gerrit/tools/bzl/classpath.bzl
David Ostrovsky 3ed0112115 Bazel: Fix eclipse classpath generation
Since I819954da56 JUnit test is added that depends on reviewdb_proto,
however, this new dependency wasn't added to Eclipse classpath
generation machinery. Widen the visibility of that library and add
it to the transitive closure of Eclipse classpath generation.

Ad a side effect, we need to conditionally query compilation_info
attribute during classpath generation, because java_proto_library
doesn't expose this attribute.

Bug: Issue 9564
Change-Id: I4ef1be9b1f7db9764f6bc8e5571da6ba6ac211f6
2018-08-14 08:22:40 +02:00

26 lines
704 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]
ctx.file_action(
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,
)