2016-11-13 10:34:18 -08:00
|
|
|
def _classpath_collector(ctx):
|
2017-08-28 14:34:44 +02:00
|
|
|
all = depset()
|
2016-11-13 10:34:18 -08:00
|
|
|
for d in ctx.attr.deps:
|
2018-07-10 11:51:36 +02:00
|
|
|
if hasattr(d, "java"):
|
2016-11-13 08:01:08 -08:00
|
|
|
all += d.java.transitive_runtime_deps
|
|
|
|
all += d.java.compilation_info.runtime_classpath
|
2018-07-10 11:51:36 +02:00
|
|
|
elif hasattr(d, "files"):
|
2016-11-13 08:01:08 -08:00
|
|
|
all += d.files
|
2016-11-13 10:34:18 -08:00
|
|
|
|
|
|
|
as_strs = [c.path for c in all]
|
2018-07-10 11:51:36 +02:00
|
|
|
ctx.file_action(
|
|
|
|
output = ctx.outputs.runtime,
|
|
|
|
content = "\n".join(sorted(as_strs)),
|
|
|
|
)
|
2016-11-13 10:34:18 -08:00
|
|
|
|
|
|
|
classpath_collector = rule(
|
|
|
|
attrs = {
|
|
|
|
"deps": attr.label_list(),
|
|
|
|
},
|
2016-12-11 19:00:10 +09:00
|
|
|
outputs = {
|
|
|
|
"runtime": "%{name}.runtime_classpath",
|
|
|
|
},
|
|
|
|
implementation = _classpath_collector,
|
|
|
|
)
|