Previously known as higherkindness/rules_scala,
lucidsoftware/rules_scala
evolved, in part, from the need for Bazel adoption support for large,
monorepo Scala projects. Bazel is wonderful because it makes use of parallelism and caching to
vastly improve build times. However, to see these benefits, a project must first be broken down into
tiny packages and make use of fine-grained dependencies. This is not always a realistic short-term
goal for large, monorepo Scala projects.
lucidsoftware/rules_scala
used to allow for the optional use of Zinc incremental compilation to
provide a stepping stone for these projects as they migrate to Bazel. Although we still reuse code
from Zinc and the compiler bridge, this ruleset no longer supports incremental compilation.
Mitigating nondeterminism issues required introducing an enormous amount of complexity to the
compilation worker, and we eventually discovered that supporting incremental compilation added
substantial overhead to compilation times.
lucidsoftware/rules_scala
is written with maintainability and accessibility in mind. It aims to
facilitate the transition to Bazel, and to satisfy use cases throughout the Scala ecosystem.
- Support the breadth of the Scala ecosystem.
- Follow Bazel best practices.
- Be accessible and maintainable.
- Have high-quality documentation.
If the right design principles are kept, implementing additional features should be simple and straightforward.
- Simple core API modeled after Bazel's Java APIs
- Works with all sbt-compatible test frameworks
- Advanced Dependency Detection
- Errors on indirect and unused dependencies
- Buildozer suggestions for dependency errors
- Optional Worker strategy
- Scalafmt integration
- Protobuf support with ScalaPB
- Seamless integration with the Bazel IntelliJ plugin
- Customizable rules
- Multiple Scala versions in one build, including Scala 3 (Dotty).
- Optimal handling of macros and ijars
- Modern implementation using Bazel's most idiomatic APIs
lucidsoftware/rules_scala
isn't on the Bazel Central Registry, so
you'll need to pull it in via archive_override
. Be sure to replace <COMMIT>
with the
latest commit on lucid-master
and <INTEGRITY>
with the hash suggested by Bazel after the
dependency is first loaded.
MODULE.bazel
bazel_dep(name = "rules_scala_annex")
rules_scala_annex_version = "<COMMIT>"
archive_override(
module_name = "rules_scala_annex",
integrity = "<INTEGRITY>",
strip_prefix = "rules_scala-{}".format(rules_scala_annex_version),
urls = ["https://github.com/lucidsoftware/rules_scala/archive/refs/heads/{}.zip".format(rules_scala_annex_version)],
)
BUILD
load("@rules_scala_annex//rules:scala.bzl", "scala_library")
scala_library(
name = "example",
srcs = glob(["*.scala"])
)
See contributing guidelines for help on contributing to this project.
For all rules and attributes, see the Stardoc.