Skip to content

timothyklim/rules_scala3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

higherkindness/rules_scala

Build Status

higherkindness/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.

higherkindness/rules_scala allows for the optional use of Zinc incremental compilation to provide a stepping stone for these projects as they migrate to Bazel.

higherkindness/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.

Principles

  1. Support the breadth of the Scala ecosystem.
  2. Follow Bazel best practices.
  3. Be accessible and maintainable.
  4. Have high-quality documentation.

If the right design principles are kept, implementing additional features should be simple and straightforward.

Features

Usage

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Load rules scala annex
rules_scala_version = "ae99fcb08bbddfc24fef00d7b13f6c065e1df8d5"
rules_scala_sha256 = "1630fc7ecc7a4ffeabcdef73c7600eab9cf3fd2377db1f69b8ce1927560211ff"
http_archive(
    name = "rules_scala3",
    sha256 = rules_scala_sha256,
    strip_prefix = "rules_scala-{}".format(rules_scala_version),
    url = "https://github.com/higherkindness/rules_scala/archive/{}.zip".format(rules_scala_version),
)

rules_jvm_external_tag = "4.0"

rules_jvm_external_sha256 = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169"

http_archive(
    name = "rules_jvm_external",
    sha256 = rules_jvm_external_sha256,
    strip_prefix = "rules_jvm_external-{}".format(rules_jvm_external_tag),
    url = "https://github.com/bazelbuild/rules_jvm_external/archive/{}.zip".format(rules_jvm_external_tag),
)

load("@rules_scala3//rules/scala:workspace.bzl", "scala_register_toolchains", "scala_repositories")
scala_repositories()
scala_register_toolchains()

load("@rules_scala3//rules/scalafmt:config.bzl", "scalafmt_default_config")
scalafmt_default_config()

# Load bazel skylib and google protobuf
bazel_skylib_tag = "1.0.2"
bazel_skylib_sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44"
http_archive(
    name = "bazel_skylib",
    sha256 = bazel_skylib_sha256,
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{tag}/bazel-skylib-{tag}.tar.gz".format(tag = bazel_skylib_tag),
        "https://github.com/bazelbuild/bazel-skylib/releases/download/{tag}/bazel-skylib-{tag}.tar.gz".format(tag = bazel_skylib_tag),
    ],
)

protobuf_tag = "3.10.1"
protobuf_sha256 = "678d91d8a939a1ef9cb268e1f20c14cd55e40361dc397bb5881e4e1e532679b1"
http_archive(
    name = "com_google_protobuf",
    sha256 = protobuf_sha256,
    strip_prefix = "protobuf-{}".format(protobuf_tag),
    type = "zip",
    url = "https://github.com/protocolbuffers/protobuf/archive/v{}.zip".format(protobuf_tag),
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

# Specify the scala compiler we wish to use; in this case, we'll use the default one specified in rules_scala
bind(
    name = "default_scala",
    actual = "@rules_scala3//scala:zinc_2_13",
)

BUILD

load("@rules_scala3//rules:scala.bzl", "scala_library")

scala_library(
  name = "example",
  srcs = glob(["**/*.scala"])
)

Further Documentation

See contributing guidlines for help on contributing to this project.

For all rules and attributes, see the Stardoc.