@@ -17,18 +17,18 @@ This project defines core build rules for [Scala](https://www.scala-lang.org/) t
17
17
18
18
## Rules
19
19
20
- - [ scala_library] ( docs/scala_library.md )
21
- - [ scala_macro_library] ( docs/scala_macro_library.md )
22
- - [ scala_binary] ( docs/scala_binary.md )
23
- - [ scala_test] ( docs/scala_test.md )
24
- - [ scala_repl] ( docs/scala_repl.md )
25
- - [ scala_library_suite] ( docs/scala_library_suite.md )
26
- - [ scala_test_suite] ( docs/scala_test_suite.md )
27
- - [ thrift_library] ( docs/thrift_library.md )
28
- - [ scala_proto_library] ( docs/scala_proto_library.md )
29
- - [ scala_toolchain] ( docs/scala_toolchain.md )
30
- - [ scala_import] ( docs/scala_import.md )
31
- - [ scala_doc] ( docs/scala_doc.md )
20
+ - [ scala_library] ( ./ docs/scala_library.md)
21
+ - [ scala_macro_library] ( ./ docs/scala_macro_library.md)
22
+ - [ scala_binary] ( ./ docs/scala_binary.md)
23
+ - [ scala_test] ( ./ docs/scala_test.md)
24
+ - [ scala_repl] ( ./ docs/scala_repl.md)
25
+ - [ scala_library_suite] ( ./ docs/scala_library_suite.md)
26
+ - [ scala_test_suite] ( ./ docs/scala_test_suite.md)
27
+ - [ thrift_library] ( ./ docs/thrift_library.md)
28
+ - [ scala_proto_library] ( ./ docs/scala_proto_library.md)
29
+ - [ scala_toolchain] ( ./ docs/scala_toolchain.md)
30
+ - [ scala_import] ( ./ docs/scala_import.md)
31
+ - [ scala_doc] ( ./ docs/scala_doc.md)
32
32
33
33
## Getting started
34
34
@@ -612,13 +612,61 @@ In `WORKSPACE`, this `register_toolchains()` call must come before calling
612
612
` scala_register_toolchains() ` to ensure this toolchain takes precedence. The
613
613
same exact call will also work in ` MODULE.bazel ` .
614
614
615
+ ### Bzlmod configuration (coming soon!)
616
+
617
+ The upcoming Bzlmod implementation will funnel through the ` scala_toolchains() `
618
+ macro as well, ensuring maximum compatibility with ` WORKSPACE ` configurations.
619
+ The equivalent Bzlmod configuration for the ` scala_toolchains() ` configuration
620
+ above would be:
621
+
622
+ ``` py
623
+ bazel_dep(name = " rules_scala" , version = " 7.0.0" )
624
+
625
+ scala_config = use_extension(
626
+ " @rules_scala//scala/extensions:config.bzl" ,
627
+ " scala_config" ,
628
+ )
629
+
630
+ scala_config.settings(scala_version = " 2.13.16" )
631
+
632
+ scala_deps = use_extension(
633
+ " @rules_scala//scala/extensions:deps.bzl" ,
634
+ " scala_deps" ,
635
+ )
636
+
637
+ scala_deps.toolchains(
638
+ scalafmt = True ,
639
+ scalatest = True ,
640
+ )
641
+ ```
642
+
643
+ The module extensions will call ` scala_config() ` and ` scala_toolchains() `
644
+ respectively. The ` MODULE.bazel ` file for ` rules_scala ` declares its own
645
+ dependencies via ` bazel_dep() ` , allowing Bazel to resolve versions according to
646
+ the main repository/root module configuration. It also calls
647
+ [ ` register_toolchains() ` ] [ reg_tool ] , so you don't have to (unless you want to
648
+ register a specific toolchain to resolve first).
649
+
650
+ [ reg_tool ] : https://bazel.build/rules/lib/globals/module#register_toolchains
651
+
652
+ The ` MODULE.bazel ` files in this repository will also provide many examples
653
+ (when they land per bazelbuild/rules_scala #1482 ).
654
+
615
655
#### Copy ` register_toolchains() ` calls from ` WORKSPACE ` to ` MODULE.bazel `
616
656
617
657
The ` MODULE.bazel ` file from ` rules_scala ` will automatically call
618
658
` register_toolchains() ` for toolchains configured via its ` scala_deps ` module
619
659
extension. However, you must register explicitly in your ` MODULE.bazel ` file any
620
660
toolchains that you want to take precedence over the toolchains configured by
621
- ` scala_deps ` .
661
+ ` scala_deps ` . This includes any [ ` scala_toolchain ` ] ( ./docs/scala_toolchain.md )
662
+ targets defined in your project, or optional ` rules_scala ` toolchains like the
663
+ dependency checker error toolchain from above:
664
+
665
+ ``` py
666
+ register_toolchains(
667
+ " @rules_scala//scala:unused_dependency_checker_error_toolchain" ,
668
+ )
669
+ ```
622
670
623
671
### ` @io_bazel_rules_scala_config ` is now ` @rules_scala_config `
624
672
@@ -712,46 +760,6 @@ supporting Bazel + MSVC builds per:
712
760
Enable [ protocol compiler toolchainization] ( #protoc ) to fix broken Windows
713
761
builds by avoiding ` @com_google_protobuf//:protoc ` recompilation.
714
762
715
- ### Bzlmod configuration (coming soon!)
716
-
717
- The upcoming Bzlmod implementation will funnel through the ` scala_toolchains() `
718
- macro as well, ensuring maximum compatibility with ` WORKSPACE ` configurations.
719
- The equivalent Bzlmod configuration for the ` scala_toolchains() ` configuration
720
- above would be:
721
-
722
- ``` py
723
- bazel_dep(name = " rules_scala" , version = " 7.0.0" )
724
-
725
- scala_config = use_extension(
726
- " @rules_scala//scala/extensions:config.bzl" ,
727
- " scala_config" ,
728
- )
729
-
730
- scala_config.settings(scala_version = " 2.13.16" )
731
-
732
- scala_deps = use_extension(
733
- " @rules_scala//scala/extensions:deps.bzl" ,
734
- " scala_deps" ,
735
- )
736
-
737
- scala_deps.toolchains(
738
- scalafmt = True ,
739
- scalatest = True ,
740
- )
741
- ```
742
-
743
- The module extensions will call ` scala_config() ` and ` scala_toolchains() `
744
- respectively. The ` MODULE.bazel ` file for ` rules_scala ` declares its own
745
- dependencies via ` bazel_dep() ` , allowing Bazel to resolve versions according to
746
- the main repository/root module configuration. It also calls
747
- [ ` register_toolchains() ` ] [ reg_tool ] , so you don't have to (unless you want to
748
- register a specific toolchain to resolve first).
749
-
750
- [ reg_tool ] : https://bazel.build/rules/lib/globals/module#register_toolchains
751
-
752
- The ` MODULE.bazel ` files in this repository will also provide many examples
753
- (when they land per bazelbuild/rules_scala #1482 ).
754
-
755
763
### Embedded resource paths no longer begin with ` external/<repo_name> `
756
764
757
765
[ Any program compiled with an external repo asset in its 'resources' attribute
0 commit comments