This rule is used for building Scala projects with Bazel. There are currently four rules, scala_library, scala_macro_library, scala_binary and scala_test.
In order to use scala_library, scala_macro_library, and scala_binary, you must add the following to your WORKSPACE file:
load("@bazel_tools//tools/build_defs/scala:scala.bzl", "scala_repositories") scala_repositories()
scala_library(name, srcs, deps, data, main_class, resources, scalacopts, jvm_flags) scala_macro_library(name, srcs, deps, data, main_class, resources, scalacopts, jvm_flags)
scala_library generates a .jar file from .scala source files. This rule also creates an interface jar to avoid recompiling downstream targets unless then interface changes.
scala_macro_library generates a .jar file from .scala source files when they contain macros. For macros, there are no interface jars because the macro code is executed at compile time. For best performance, you want very granular targets until such time as the zinc incremental compiler can be supported.
In order to make a java rule use this jar file, use the java_import rule.
scala_binary(name, srcs, deps, data, main_class, resources, scalacopts, jvm_flags)
scala_binary generates a Scala executable. It may depend on scala_library, scala_macro_library and java_library rules.
A scala_binary requires a main_class attribute.
scala_test(name, srcs, suites, deps, data, main_class, resources, scalacopts, jvm_flags)
scala_test generates a Scala executable which runs unit test suites written using the scalatest library. It may depend on scala_library, scala_macro_library and java_library rules.
A scala_test requires a suites attribute, specifying the fully qualified (canonical) names of the test suites to run. In a future version, we might investigate lifting this requirement.