rules_scala
rules_scala copied to clipboard
plus-one dependency tracking does not handle custom rules
The plus-one reduced classpath is implemented using an aspect that propagates along deps and exports. This doesn't work with custom rules that declare a custom attribute and call java_common.compile directly.
We can work around this by exporting the custom dependencies. This is not ideal for all cases though.
One potential solution is to expose a provider (maybe PlusOneDeps itself) so that custom rules can report their direct dependencies.
@jdai8 I'm not sure I fully follow your idea. Any chance you can make a small POC PR to demonstrate what you have in mind?
Consider a custom rule my_java_rule with a custom_dep attribute:
def my_java_rule_impl(ctx):
...
java_info = java_common.compile(
ctx = ctx,
source_files = ctx.attrs.srcs,
deps = [ctx.attr.custom_dep[JavaInfo]],
...
)
return [java_info]
my_java_rule(
name = "foo",
...
custom_dep = "//:second_order_dep",
)
scala_library(
name = "bar",
srcs = ...,
deps = [
":foo",
]
)
If we use the plus-one mode, I'd expect second_order_dep to be on the classpath for bar, but it's not.