Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Latest commit

 

History

History
176 lines (172 loc) · 5.87 KB

scala_library.md

File metadata and controls

176 lines (172 loc) · 5.87 KB

scala_library

scala_library(
    name,
    srcs,
    deps,
    runtime_deps,
    exports,
    data,
    main_class,
    resources,
    resource_strip_prefix,
    scalacopts,
    jvm_flags,
    scalac_jvm_flags,
    javac_jvm_flags,
    unused_dependency_checker_mode
)

scala_library generates a .jar file from .scala source files. This rule also creates an interface jar to avoid recompiling downstream targets unless their interface changes.

In order to have a Java rule use this jar file, use the java_import rule.

Attributes
name

Name, required

A unique name for this target

srcs

List of labels, required

List of Scala .scala source files used to build the library. These may be .srcjar jar files that contain source code.

deps

List of labels, optional

List of other libraries to linked to this library target. These must be jvm targets (scala_library, java_library, java_import, etc...)

runtime_deps

List of labels, optional

List of other libraries to put on the classpath only at runtime. This is rarely needed in Scala. These must be jvm targets (scala_library, java_library, java_import, etc...)

exports

List of labels, optional

List of targets to add to the dependencies of those that depend on this target. Similar to the `java_library` parameter of the same name. Use this sparingly as it weakens the precision of the build graph. These must be jvm targets (scala_library, java_library, java_import, etc...)

data

List of labels, optional

List of files needed by this rule at runtime.

main_class

String, optional

Name of class with main() method to use as an entry point

The value of this attribute is a class name, not a source file. The class must be available at runtime: it may be compiled by this rule (from srcs) or provided by direct or transitive dependencies (through deps). If the class is unavailable, the binary will fail at runtime; there is no build-time check.

resources

List of labels; optional

A list of data files to be included in the JAR.

resource_strip_prefix

String; optional

The path prefix to strip from Java resources. If specified, this path prefix is stripped from every file in the `resources` attribute. It is an error for a resource file not to be under this directory.

scalacopts

List of strings; optional

Extra compiler options for this library to be passed to scalac. Subject to Make variable substitution and Bourne shell tokenization.

jvm_flags

List of strings; optional; deprecated

Deprecated, superseded by scalac_jvm_flags and javac_jvm_flags. Is not used and is kept as backwards compatibility for the near future. Effectively jvm_flags is now an executable target attribute only.

scalac_jvm_flags

List of strings; optional

List of JVM flags to be passed to scalac after the scalacopts. Subject to Make variable substitution and Bourne shell tokenization.

javac_jvm_flags

List of strings; optional

List of JVM flags to be passed to javac after the javacopts. Subject to Make variable substitution and Bourne shell tokenization.

unused_dependency_checker_mode

String; optional

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