@@ -143,8 +143,8 @@ load("@rules_scala//:scala_config.bzl", "scala_config")
143
143
# scala_config(scala_version = "2.13.16")
144
144
#
145
145
# You may define your own custom toolchain using Maven artifact dependencies
146
- # configured by your `WORKSPACE` file, imported using external loader like
147
- # https://github.com/bazelbuild/rules_jvm_external.
146
+ # configured by your `WORKSPACE` file, imported using an external loader like
147
+ # https://github.com/bazelbuild/rules_jvm_external. See docs/scala_toolchain.md.
148
148
scala_config()
149
149
150
150
load(
@@ -153,16 +153,17 @@ load(
153
153
" scala_toolchains" ,
154
154
)
155
155
156
- # Defines a default toolchain repo for the configured Scala version that
157
- # loads Maven deps like the Scala compiler and standard libs. On production
158
- # projects, you may consider defining a custom toolchain to use your project's
159
- # required dependencies instead.
156
+ # Defines a default toolchain repo for the configured Scala version that loads
157
+ # Maven deps like the Scala compiler and standard libs. Enable other builtin
158
+ # toolchains by setting their corresponding parameters to `True`. See the
159
+ # `scala_toolchains()` docstring for all builtin toolchain configuration
160
+ # options.
160
161
#
161
- # Optional builtin rules_scala toolchains may be configured by setting
162
- # parameters as documented in the `scala_toolchains()` docstring.
163
- scala_toolchains(
164
- scalatest = True ,
165
- )
162
+ # On production projects, you may consider defining a custom toolchain to use
163
+ # your project's required dependencies instead. In that case, you can omit
164
+ # ` scala_toolchains()` or explicitly set `scala = False` if you use it to
165
+ # instantiate other builtin toolchains.
166
+ scala_toolchains( )
166
167
167
168
scala_register_toolchains()
168
169
```
@@ -360,12 +361,27 @@ single_version_override(
360
361
361
362
#### ` protobuf ` patch setup under ` WORKSPACE `
362
363
363
- [ ` scala/deps.bzl ` ] ( ./scala/deps.bzl ) already applies the ` protobuf ` patch by
364
- default. If you need to apply it yourself, you can also copy it to your repo as
365
- described in the Bzlmod setup above. Then follow the example in ` scala/deps.bzl `
366
- to apply it in your own ` http_archive ` call.
364
+ [ ` scala/deps.bzl ` ] ( ./scala/deps.bzl ) currently applies the ` protobuf ` patch to ` protobuf ` v30.1.
367
365
368
- However, ` WORKSPACE ` must include the ` host_platform_repo ` snippet from
366
+ If you need to apply the patch to a different version of ` protobuf ` , copy it to
367
+ your repo as described in the Bzlmod setup above. Then apply it in your own
368
+ ` http_archive ` call:
369
+
370
+ ``` py
371
+ http_archive(
372
+ name = " com_google_protobuf" ,
373
+ sha256 = " 1451b03faec83aed17cdc71671d1bbdfd72e54086b827f5f6fd02bf7a4041b68" ,
374
+ strip_prefix = " protobuf-30.1" ,
375
+ url = " https://github.com/protocolbuffers/protobuf/archive/refs/tags/v30.1.tar.gz" ,
376
+ repo_mapping = {" @com_google_absl" : " @abseil-cpp" },
377
+ patches = [" //protobuf.patch" ],
378
+ patch_args = [" -p1" ],
379
+ )
380
+ ```
381
+
382
+ #### Setting up the ` @host_platform ` repo under ` WORKSPACE `
383
+
384
+ ` WORKSPACE ` must include the ` host_platform_repo ` snippet from
369
385
[ Getting started] ( #getting-started ) to work around bazelbuild/bazel #22558 :
370
386
371
387
``` py
@@ -744,8 +760,6 @@ load(
744
760
" scala_toolchains" ,
745
761
)
746
762
747
- # The `scala_version` toolchain repos used by `scala_library` and `scala_binary`
748
- # are _always_ configured, but all others are optional.
749
763
scala_toolchains(
750
764
scalafmt = True,
751
765
scalatest = True,
@@ -791,9 +805,10 @@ same exact call will also work in `MODULE.bazel`.
791
805
### Disabling builtin Scala toolchains when defining custom Scala toolchains
792
806
793
807
When [ defining a 'scala_toolchain()' using custom compiler JARs] (
794
- docs/scala_toolchain.md#b-defining-your-own-scala_toolchain), while using
795
- ` scala_toolchains() ` to instantiate builtin toolchains (like the [ protoc
796
- toolchain] ( #protoc ) ), set ` scala = False ` :
808
+ docs/scala_toolchain.md#b-defining-your-own-scala_toolchain), don't use
809
+ ` scala_toolchains() ` if you don't need any other builtin toolchains.
810
+
811
+ If you do need other builtin toolchains, then set ` scala = False ` :
797
812
798
813
``` py
799
814
# WORKSPACE
0 commit comments