Skip to content

Commit 3615365

Browse files
committed
Update repo_mapping docs, fix "scalapb" typo
1 parent 1921bdc commit 3615365

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

README.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,14 @@ v6.x:
168168
name__ unless your `BUILD` files or those of your dependencies require it
169169
(bazelbuild/rules_scala#1696).
170170

171+
Update your project's `@io_bazel_rules_scala` references to `@rules_scala`
172+
if possible. Otherwise, use `repo_name = "io_bazel_rules_scala"` in
173+
`bazel_dep()` or `name = "io_bazel_rules_scala"` in `http_archive`.
174+
171175
You can use the `repo_mapping` attribute of `http_archive` or equivalent
172-
Bzlmod mechanisms to translate `@rules_scala` to `@io_bazel_rules_scala`
173-
for dependencies. See the ['@io_bazel_rules_scala_config' is now
174-
'@rules_scala_config'](#map) section below for details. (That section is
176+
Bzlmod mechanisms to translate `@rules_scala` to `@io_bazel_rules_scala` for
177+
dependencies. See the [Translating repo names for
178+
dependencies](#repo-mapping) section below for details. (That section is
175179
about `@rules_scala_config`, but the same mechanisms apply.)
176180

177181
- __`rules_scala` v7.0.0 introduces a new `scala_toolchains()` API that is
@@ -368,7 +372,7 @@ Please check [cross-compilation.md](docs/cross-compilation.md) for more details
368372
## Compatible Bazel versions
369373

370374
Bazel compatibility is tied directly to the versions of `protobuf` required by
371-
Bazel and `rules_java`, and their compatibility with [scalabp/ScalaPB](
375+
Bazel and `rules_java`, and their compatibility with [scalapb/ScalaPB](
372376
https://github.com/scalapb/ScalaPB) Maven artifacts. For extensive analysis,
373377
see bazelbuild/rules_scala#1647.
374378

@@ -675,23 +679,18 @@ register_toolchains(
675679
)
676680
```
677681

678-
### <a id="map"></a>`@io_bazel_rules_scala_config` is now `@rules_scala_config`
682+
### `@io_bazel_rules_scala_config` is now `@rules_scala_config`
679683

680684
Since `@io_bazel_rules_scala` is no longer hardcoded in `rules_scala` internals,
681685
we've shortened `@io_bazel_rules_scala_config` to `@rules_scala_config`. This
682686
shouldn't affect most users, but it may break some builds using
683687
`@io_bazel_rules_scala_config` to define custom [cross-compilation targets](
684688
./docs/cross-compilation.md).
685689

686-
If you can't update `@io_bazel_rules_scala_config` references in your own
687-
project immediately, or have dependencies that require it, use the workarounds
688-
below. (The same workarounds also apply if you need to translate `@rules_scala`
689-
to `@io_bazel_rules_scala`.)
690-
691-
#### Bzlmod
692-
693-
You can remap `@rules_scala_config` via [`use_repo()`] if you need it in your
694-
own project:
690+
If your project uses Bzlmod, you can remap `@io_bazel_rules_scala_config` to
691+
`@rules_scala_config` for your own project via [`use_repo()`]. Use this only if
692+
updating your project's own `@io_bazel_rules_scala_config` references isn't
693+
immediately feasible.
695694

696695
[`use_repo()`]: https://bazel.build/rules/lib/globals/module#use_repo
697696

@@ -704,8 +703,20 @@ scala_config = use_extension(
704703
use_repo(scala_config, io_bazel_rules_scala_config = "rules_scala_config")
705704
```
706705

707-
For [`bazel_dep()`][] dependencies, use [`override_repo()`][] to
708-
override `@io_bazel_rules_scala_config` with `@rules_scala_config`:
706+
If your project uses `WORKSPACE` you _must_ update all
707+
`@io_bazel_rules_scala_config` references to `@rules_scala_config`. There is no
708+
`use_repo()` equivalent.
709+
710+
#### <a id="repo-mapping"></a>Translating repo names for dependencies
711+
712+
For any dependencies referencing `@io_bazel_rules_scala_config`, use the workarounds
713+
below. The same workarounds for your project's dependencies also apply to
714+
translating `@rules_scala` to `@io_bazel_rules_scala`.
715+
716+
#### Bzlmod
717+
718+
For module extensions, use [`override_repo()`][] to override
719+
`@io_bazel_rules_scala_config` with `@rules_scala_config`:
709720

710721
```py
711722
bazel_dep(name = "foo", version = "1.0.0")
@@ -714,12 +725,12 @@ foo_ext = use_extension("@foo//:ext.bzl", "foo_ext")
714725
override_repo(foo_ext, io_bazel_rules_scala_config = "rules_scala_config")
715726
```
716727

717-
[`bazel_dep()`]: https://bazel.build/rules/lib/globals/module#bazel_dep
718-
[`override_repo()`]: https://bazel.build/rules/lib/globals/module#override_repo
719-
720-
For [`archive_override()`][] and [`git_override()`][] dependencies, use the
721-
`repo_mapping` attribute passed through to the underlying [`http_archive()`][]
722-
and [`git_repository()`][] rules:
728+
[`bazel_dep()`][] dependencies may still require `@io_bazel_rules_scala_config`
729+
(or `@io_bazel_rules_scala`) outside of a module extension. In this case, to
730+
avoid using the old name in your own project, use [`archive_override()`][] or
731+
[`git_override()`][] with the `repo_mapping` attribute. These overrides pass the
732+
`repo_mapping` through to the underlying [`http_archive()`][] and
733+
[`git_repository()`][] rules:
723734

724735
```py
725736
archive_override(
@@ -731,14 +742,16 @@ archive_override(
731742
)
732743
```
733744

745+
[`override_repo()`]: https://bazel.build/rules/lib/globals/module#override_repo
746+
[`bazel_dep()`]: https://bazel.build/rules/lib/globals/module#bazel_dep
734747
[`archive_override()`]: https://bazel.build/rules/lib/globals/module#archive_override
735748
[`git_override()`]: https://bazel.build/rules/lib/globals/module#git_override
736749
[`http_archive()`]: https://bazel.build/rules/lib/repo/http#http_archive-repo_mapping
737750
[`git_repository()`]: https://bazel.build/rules/lib/repo/git#git_repository-repo_mapping
738751

739752
#### `WORKSPACE`
740753

741-
Use the `repo_mapping` attribute of [`http_archive()`][] or
754+
For dependencies, use the `repo_mapping` attribute of [`http_archive()`][] or
742755
[`git_repository()`][]:
743756

744757
```py

0 commit comments

Comments
 (0)