@@ -25,7 +25,7 @@ scala_toolchains()
2525scala_register_toolchains()
2626```
2727
28- ### B) Defining your own ` scala_toolchain ` requires 2 steps
28+ ### B) Defining your own ` scala_toolchain `
2929
3030#### Step 1
3131
@@ -65,7 +65,7 @@ load("@rules_scala//scala:scala.bzl", "setup_scala_toolchain")
6565
6666setup_scala_toolchain(
6767 name = " my_toolchain" ,
68- # configure toolchain dependecies
68+ # configure toolchain dependencies
6969 parser_combinators_deps = [
7070 " @maven//:org_scala_lang_modules_scala_parser_combinators_2_12" ,
7171 ],
@@ -101,6 +101,32 @@ Register your custom toolchain:
101101register_toolchains(" //toolchains:my_scala_toolchain" )
102102```
103103
104+ #### Step 3 (optional)
105+
106+ If you use ` scala_toolchains() ` to instantiate other builtin toolchains, set
107+ ` validate_scala_version = False ` :
108+
109+ ``` py
110+ # WORKSPACE
111+ scala_toolchains(
112+ validate_scala_version = False ,
113+ # ...other toolchain parameters...
114+ )
115+ ```
116+
117+ This prevents ` rules_scala ` from checking that the Scala versions specified via
118+ ` scala_config ` match the ` scala_version ` values from
119+ ` third_party/repositories/scala_*.bzl ` .
120+
121+ ` scala_toolchains() ` uses these ` scala_*.bzl ` files to instantiate dependency
122+ JAR repositories required by the builtin toolchains. It always instantiates a
123+ default Scala toolchain, along with its compiler JAR repositories, since [ most
124+ users expect this behavior] [ 1633-comment ] . (As always, calling
125+ ` register_toolchains() ` on your own toolchain in ` MODULE.bazel ` , or before
126+ ` scala_register_toolchains() ` in ` WORKSPACE ` , overrides the builtin toolchain.)
127+
128+ [ 1633-comment ] : https://github.com/bazelbuild/rules_scala/pull/1633#discussion_r1834378901
129+
104130## Configuration options
105131
106132The following attributes apply to both ` scala_toolchain ` and
@@ -168,7 +194,7 @@ The following attributes apply to both `scala_toolchain` and
168194 <td>
169195 <p><code>String; optional</code></p>
170196 <p>
171- Enable unused dependency checking (see <a href="https://github.com/bazelbuild/rules_scala #experimental-unused-dependency-checking">Unused dependency checking</a>).
197+ Enable unused dependency checking (see <a href="./dependency-tracking.md #experimental-unused-dependency-checking">Unused dependency checking</a>).
172198 Possible values are: <code>off</code>, <code>warn</code> and <code>error</code>.
173199 </p>
174200 </td>
0 commit comments