rules_scala icon indicating copy to clipboard operation
rules_scala copied to clipboard

Failing The Build Scalafmt

Open borkaehw opened this issue 5 years ago • 3 comments

  1. 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"],
    )
  1. Have scalafmt_scala_library actually be a macro that delegates to _scalafmt_scala_library_rule and scala_fmt_test.
  2. 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

borkaehw avatar Feb 07 '20 20:02 borkaehw

Thanks! Can you elaborate on 3? The rule will use the toolchain to decide it to run the action or not?

ittaiz avatar Feb 08 '20 12:02 ittaiz

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.

gergelyfabian avatar Apr 24 '20 07:04 gergelyfabian

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)

virusdave avatar Feb 04 '22 01:02 virusdave