blob: f997fcf8ea02b4cb67979ba0017961bb37fe2988 [file] [log] [blame]
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,
)