rules_scala
rules_scala copied to clipboard
Failing The Build Scalafmt
- Have an independent macro that users set up in addition to their
scalafmt_scala_library
targets which looks something like:
def scala_fmt_test(name,target):
native.sh_test(
name = name + "_scala_fmt_test",
srcs = [target + ".format-test"],
)
- Have
scalafmt_scala_library
actually be a macro that delegates to_scalafmt_scala_library_rule
andscala_fmt_test
. - If you want this to be toggled via a toolchain then you can do something like 2 but instead of using a regular
sh_test
you can write one of your own that will depend on the toolchain.
Reference from https://github.com/bazelbuild/rules_scala/pull/912#issuecomment-578927303
Thanks! Can you elaborate on 3? The rule will use the toolchain to decide it to run the action or not?
This would be very useful. In fact rules_scala implementation from higherkindness provides a similar feature: https://github.com/higherkindness/rules_scala/blob/master/docs/scalafmt.md#scalafmt.
I don't suppose anyone has made this work? I also went down the "create a wrapping sh_test
that invokes the foo.format-test
path, and ran into the same issue of missing manifest file (and, presumably, the formatted output files)