Skip to content

Latest commit

 

History

History
112 lines (100 loc) · 3.29 KB

scala_toolchain.md

File metadata and controls

112 lines (100 loc) · 3.29 KB

scala_toolchain

scala_toolchain allows you to define global configuration to all Scala targets.

Some scala_toolchain must be registered!

Several options to configure scala_toolchain:

A) Use the default scala_toolchain:

In your workspace file add the following lines:

# WORKSPACE
# register default scala toolchain
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()

B) Defining your own scala_toolchain requires 2 steps:

  1. Add your own definition of scala_toolchain to a BUILD file:

    # //toolchains/BUILD
    load("@io_bazel_rules_scala//scala:scala_toolchain.bzl", "scala_toolchain")
    
    scala_toolchain(
        name = "my_toolchain_impl",
        scalacopts = ["-Ywarn-unused"],
        unused_dependency_checker_mode = "off",
        visibility = ["//visibility:public"]
    )
    
    toolchain(
        name = "my_scala_toolchain",
        toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type",
        toolchain = "my_toolchain_impl",
        visibility = ["//visibility:public"]
    )
  2. Register your custom toolchain from WORKSPACE:

    # WORKSPACE
    register_toolchains("//toolchains:my_scala_toolchain")
Attributes
scalacopts

List of strings; optional

Extra compiler options for this binary to be passed to scalac.

scalac_jvm_flags

List of strings; optional

List of JVM flags to be passed to scalac. For example ["-Xmx5G"] could be passed to control memory usage of Scalac.

This is overridden by the scalac_jvm_flags attribute on individual targets.

scala_test_jvm_flags

List of strings; optional

List of JVM flags to be passed to the ScalaTest runner. For example ["-Xmx5G"] could be passed to control memory usage of the ScalaTest runner.

This is overridden by the jvm_flags attribute on individual targets.

unused_dependency_checker_mode

String; optional

Enable unused dependency checking (see Unused dependency checking). Possible values are: off, warn and error.

enable_code_coverage_aspect

"on" or "off"; optional; defaults to "off"

This enables instrumenting tests with jacoco code coverage.