Skip to content

Conversation

@meteorcloudy
Copy link
Member

@meteorcloudy meteorcloudy commented Jul 4, 2025

  • Updated protobuf and grpc to the latest version (protobuf -> 31.1, grpc -> 1.73.1)
  • apple_support was updated due to protobuf and addressed a few breaking changes
  • Applied new protobuf patch to address newly discovered issues (1. lite_runtime_only visibility, 2. protobuf maven install name, 3. cross-compile for windows arm64)
  • Removed checked-in grpc rules under third_party and migrated to using the official one.
  • Re-organized bazel_dep in MODULE.bazel, added repo_name=None for in-direct bazel modules.
  • Updated Maven jar versions.

@meteorcloudy meteorcloudy marked this pull request as draft July 4, 2025 14:39
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jul 4, 2025
@iancha1992 iancha1992 added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jul 8, 2025
@meteorcloudy meteorcloudy marked this pull request as ready for review July 9, 2025 12:54
@meteorcloudy meteorcloudy requested a review from Wyverald July 9, 2025 12:54
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jul 10, 2025
mbland added a commit to mbland/rules_scala that referenced this pull request Jul 24, 2025
Resolves the following `last_green` CI build error resulting from the
following changes appearing in Bazel 9.0.0-pre.20250714.1:

- https://buildkite.com/bazel/rules-scala-scala/builds/5701#019839bb-2124-4600-a91c-ece2eedc46fa/122-218
- https://github.com/bazelbuild/bazel/pull/26493/files#diff-47a01c886ef9dc97641591dd4dd08157ef1414496979456380830acc9f694e65R67-R72
- https://github.com/bazelbuild/bazel/pull/26493/files#diff-47a01c886ef9dc97641591dd4dd08157ef1414496979456380830acc9f694e65R101

```txt
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: scala/scala_maven_import_external.bzl:145:29:
  An error occurred during the fetch of repository
  '+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20':

  Traceback (most recent call last):
    File "scala/scala_maven_import_external.bzl", line 145, column 29,
    in _jvm_import_external_impl
      (repository_ctx.attr.visibility or

Error: unknown attribute visibility

ERROR: no such package
    '@@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20//':
    unknown attribute visibility

ERROR: test/proto/custom_generator/BUILD.bazel:44:22:
  //test/proto/custom_generator:scalapb_worker_deps_provider depends on
  @@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20//:scala_proto_rules_scalapb_protoc_gen_2_12_20
  in repository
  @@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20
  which failed to fetch.

  no such package
  '@@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20//':
  unknown attribute visibility

ERROR: Analysis of target
  '//test/proto/custom_generator:scala_proto_deps_toolchain_def' failed;
  build aborted: Analysis failed
```

Another problem remains, but it appears to be on Bazel's end per
bazelbuild/bazel#26579 (stemming from bazelbuild/bazel#26477):

```txt
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.

ERROR: src/java/io/bazel/rulesscala/coverage/instrumenter/BUILD:3:12:
  error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.
  and referenced by
  '//src/java/io/bazel/rulesscala/coverage/instrumenter:instrumenter'

ERROR: Analysis of target '//test/aspect:scala_junit_test' failed;
  build aborted: Analysis failed
```

Neither of these errors occurred when building with Bazel
9.0.0-pre.20250710.1.

The `scala/private/extensions/dev_deps.bzl` update eliminates the
warning:

```txt
DEBUG: scala/scala_maven_import_external.bzl:80:14:
  'jar_sha256' is deprecated. Please use 'artifact_sha256'
```

---

It seems prudent to address this `last_green` failure separately from
bumping dependency versions before releasing v7.1.0. We'll have to wait
for an upstream fix for bazelbuild/bazel#26579, however. Once it
appears, though, the `last_green` build should succeed again, with this
change already in place.

Also, ostensibly, `repository_ctx.attr.visibility` was never a valid
value for `package(default_visibility = ...)`. Removing it seems more
correct than `getattr(repository_ctx, "visibility", [])`.
simuons pushed a commit to bazel-contrib/rules_scala that referenced this pull request Jul 24, 2025
Resolves the following `last_green` CI build error resulting from the
following changes appearing in Bazel 9.0.0-pre.20250714.1:

- https://buildkite.com/bazel/rules-scala-scala/builds/5701#019839bb-2124-4600-a91c-ece2eedc46fa/122-218
- https://github.com/bazelbuild/bazel/pull/26493/files#diff-47a01c886ef9dc97641591dd4dd08157ef1414496979456380830acc9f694e65R67-R72
- https://github.com/bazelbuild/bazel/pull/26493/files#diff-47a01c886ef9dc97641591dd4dd08157ef1414496979456380830acc9f694e65R101

```txt
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: scala/scala_maven_import_external.bzl:145:29:
  An error occurred during the fetch of repository
  '+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20':

  Traceback (most recent call last):
    File "scala/scala_maven_import_external.bzl", line 145, column 29,
    in _jvm_import_external_impl
      (repository_ctx.attr.visibility or

Error: unknown attribute visibility

ERROR: no such package
    '@@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20//':
    unknown attribute visibility

ERROR: test/proto/custom_generator/BUILD.bazel:44:22:
  //test/proto/custom_generator:scalapb_worker_deps_provider depends on
  @@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20//:scala_proto_rules_scalapb_protoc_gen_2_12_20
  in repository
  @@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20
  which failed to fetch.

  no such package
  '@@+scala_deps+scala_proto_rules_scalapb_protoc_gen_2_12_20//':
  unknown attribute visibility

ERROR: Analysis of target
  '//test/proto/custom_generator:scala_proto_deps_toolchain_def' failed;
  build aborted: Analysis failed
```

Another problem remains, but it appears to be on Bazel's end per
bazelbuild/bazel#26579 (stemming from bazelbuild/bazel#26477):

```txt
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.

ERROR: src/java/io/bazel/rulesscala/coverage/instrumenter/BUILD:3:12:
  error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.
  and referenced by
  '//src/java/io/bazel/rulesscala/coverage/instrumenter:instrumenter'

ERROR: Analysis of target '//test/aspect:scala_junit_test' failed;
  build aborted: Analysis failed
```

Neither of these errors occurred when building with Bazel
9.0.0-pre.20250710.1.

The `scala/private/extensions/dev_deps.bzl` update eliminates the
warning:

```txt
DEBUG: scala/scala_maven_import_external.bzl:80:14:
  'jar_sha256' is deprecated. Please use 'artifact_sha256'
```

---

It seems prudent to address this `last_green` failure separately from
bumping dependency versions before releasing v7.1.0. We'll have to wait
for an upstream fix for bazelbuild/bazel#26579, however. Once it
appears, though, the `last_green` build should succeed again, with this
change already in place.

Also, ostensibly, `repository_ctx.attr.visibility` was never a valid
value for `package(default_visibility = ...)`. Removing it seems more
correct than `getattr(repository_ctx, "visibility", [])`.
mbland added a commit to mbland/rules_scala that referenced this pull request Jul 26, 2025
Uses the `bazel_worker_{api,java}` modules and a legacy `WORKSPACE` shim
to replace `@bazel_tools//src/main/protobuf:worker_protocol_java_proto`.
This, and bumping `rules_java` to 8.14.0, fixes breakages in the latest
`last_green` Bazel at commit 00b48b27aa216befc419e540919a1f1df4cda337.

Also:

- Removes the `--incompatible_autoload_externally` flag from `.bazelrc`.

- Fixes `_get_compiler_srcjar` to return empty `compiler_srcjar_objects`
  instead of returning a valid object. `test_compiler_srcjar_error
  2.12.11` from `dt_patches/dt_patch_test.sh` caught this under
  `WORKSPACE`. Added `test_fail_if_compiler_srcjar_object_is_empty` to
  `test/shell/test_compiler_sources_integrity.sh` to catch the specific
  problem sooner.

- Fixed regex in `target_file_location` from `test_helper.sh` to work
  with Bazel 6.5.0, and fixed unbound variable in `fail` message.

- Added logic to `teardown_suite` in `test_bzlmod_macros.sh` to avoid
  unbound variable breakage when running under Bazel 6.5.0.

- Added logic to skip `test_check_module_bazel_template` under Bazel 6
  in `test_version.sh`.

- Removed restriction to use `protobuf` v29 or lower with Bazel 6 from
  `README.md`.

- Added `scala_compiler_source.*` to the regular expressions for "canonical
  reproducible" messages in `dt_patches/dt_patch_test.sh`. This resolved
  a test breakage when `rules_python` began to emit a "canonical
  reproducible" message. (Also changed `--expunge` to
  `--expunge_async`.)

---

bazelbuild/bazel#26477, which also landed in the 9.0.0-pre.20250714.1
rolling release, broke the `last_green` build:

```
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.
```

The failing target, and several others, depended upon
`@bazel_tools//src/main/protobuf:worker_protocol_java_proto`. Nothing
else depends on any other target from that package. So upon @Wyverald's
advice, I attempted to use the `bazel_worker_java` module to replace
this specific dependency:

- bazelbuild/bazel#26579 (comment)

Using just `bazel_worker_java` 0.0.5 at first produced this breakage:

```txt
$ USE_BAZEL_VERSION=last_green bazel build //src/... //test/...

ERROR: .../external/bazel_worker_api+/BUILD.bazel:3:1:
  name 'proto_library' is not defined
```

This is because that version of `bazel_worker_java` still depends upon
`bazel_worker_api` 0.0.1, which didn't load `proto_library` from
`@com_google_protobuf`. Adding `bazel_worker_api` 0.0.5 directly to
`MODULE.bazel` fixed this.

The next failure was due to `rules_scala` overriding `rules_java` to be
8.12.0, whereas `last_green` now requires 8.14.0:

```txt
$ USE_BAZEL_VERSION=last_green bazel build //src/... //test/...

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  in java_library rule //src/java/io/bazel/rulesscala/jar:jar:
  Traceback (most recent call last):
    File ".../external/rules_java+/java/bazel/rules/bazel_java_library.bzl",
      line 26, column 35, in _proxy
        return bazel_java_library_rule(
    File ".../external/rules_java+/java/common/rules/impl/bazel_java_library_impl.bzl",
      line 68, column 43, in bazel_java_library_rule
        target, base_info = basic_java_library(
    File ".../external/rules_java+/java/common/rules/impl/basic_java_library_impl.bzl",
      line 127, column 49, in basic_java_library
        java_info, compilation_info = compile_action(
    File ".../external/rules_java+/java/common/rules/impl/compile_action.bzl",
      line 139, column 46, in compile_action
        java_info = _compile_private_for_builtins(
    File ".../external/rules_java+/java/private/java_common_internal.bzl",
      line 217, column 68, in compile
        get_internal_java_common().create_header_compilation_action(

Error in create_header_compilation_action:
  create_header_compilation_action() missing 2 required positional
  arguments: header_compilation_jar, header_compilation_direct_deps

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  Analysis of target '//src/java/io/bazel/rulesscala/jar:jar' failed
```

Bumping `rules_java` to 8.14.0 in the `single_version_override` fixed
that.

Finally, since there's no legacy `WORKSPACE` API in
bazelbuild/bazel-worker-api, I had to roll my own new
`workspace_compat()` macro. This macro creates
`@bazel_worker_{api,java}` repos with aliases to targets in
`@bazel-worker-api`.

Regarding `--incompatible_autoload_externally`, I'd added it in bazel-contrib#1748
when fixing problems with `WORKSPACE` builds under Bazel 8.2.1. However,
it's not really necessary, so I removed it.
mbland added a commit to mbland/rules_scala that referenced this pull request Aug 5, 2025
Uses the `bazel_worker_java` module and a legacy `WORKSPACE` shim to
replace `@bazel_tools//src/main/protobuf:worker_protocol_java_proto`.
This, and bumping `rules_java` to 8.14.0, fixes breakages in the latest
`last_green` Bazel from commit 00b48b27aa216befc419e540919a1f1df4cda337.

Note, though, that this change bumps `rules_java` to 8.15.0, since it's
now available. This change also updates:

- `gazelle`: 0.44.0 => 0.45.0
- `rules_go`: 0.55.1 => 0.56.1
- `rules_shell`: 0.5.0 => 0.5.1

Also:

- Removes the `--incompatible_autoload_externally` flag from `.bazelrc`.

- Removes the Bazel 9.0.0-pre.20250710.1 CI job added by bazel-contrib#1755, since
  it's no longer necessary given the fix from this change.

- Fixes `_get_compiler_srcjar` to return empty `compiler_srcjar_objects`
  instead of returning a valid object. `test_compiler_srcjar_error
  2.12.11` from `dt_patches/dt_patch_test.sh` caught this under
  `WORKSPACE`. Added `test_fail_if_compiler_srcjar_object_is_empty` to
  `test/shell/test_compiler_sources_integrity.sh` to catch the specific
  problem sooner.

- Fixed regex in `target_file_location` from `test_helper.sh` to work
  with Bazel 6.5.0, and fixed unbound variable in `fail` message.

- Added logic to `teardown_suite` in `test_bzlmod_macros.sh` to avoid
  unbound variable breakage when running under Bazel 6.5.0.

- Added logic to skip `test_check_module_bazel_template` under Bazel 6
  in `test_version.sh`.

- Removed restriction to use `protobuf` v29 or lower with Bazel 6 from
  `README.md`.

- Added `scala_compiler_source.*` to the regular expressions for "canonical
  reproducible" messages in `dt_patches/dt_patch_test.sh`. This resolved
  a test breakage when `rules_python` began to emit a "canonical
  reproducible" message. (Also changed `--expunge` to
  `--expunge_async`.)

---

bazelbuild/bazel#26477, which also landed in the 9.0.0-pre.20250714.1
rolling release, broke the `last_green` build:

```
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.
```

The failing target, and several others, depended upon
`@bazel_tools//src/main/protobuf:worker_protocol_java_proto`. Nothing
else depends on any other target from that package. So upon @Wyverald's
advice, I attempted to use the `bazel_worker_java` module to replace
this specific dependency:

- bazelbuild/bazel#26579 (comment)

The next failure was due to `rules_scala` overriding `rules_java` to be
8.12.0, whereas `last_green` now requires 8.14.0:

```txt
$ USE_BAZEL_VERSION=last_green bazel build //src/... //test/...

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  in java_library rule //src/java/io/bazel/rulesscala/jar:jar:
  Traceback (most recent call last):
    File ".../external/rules_java+/java/bazel/rules/bazel_java_library.bzl",
      line 26, column 35, in _proxy
        return bazel_java_library_rule(
    File ".../external/rules_java+/java/common/rules/impl/bazel_java_library_impl.bzl",
      line 68, column 43, in bazel_java_library_rule
        target, base_info = basic_java_library(
    File ".../external/rules_java+/java/common/rules/impl/basic_java_library_impl.bzl",
      line 127, column 49, in basic_java_library
        java_info, compilation_info = compile_action(
    File ".../external/rules_java+/java/common/rules/impl/compile_action.bzl",
      line 139, column 46, in compile_action
        java_info = _compile_private_for_builtins(
    File ".../external/rules_java+/java/private/java_common_internal.bzl",
      line 217, column 68, in compile
        get_internal_java_common().create_header_compilation_action(

Error in create_header_compilation_action:
  create_header_compilation_action() missing 2 required positional
  arguments: header_compilation_jar, header_compilation_direct_deps

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  Analysis of target '//src/java/io/bazel/rulesscala/jar:jar' failed
```

Bumping `rules_java` to 8.14.0 in the `single_version_override` fixed
that.

Finally, since there's no legacy `WORKSPACE` API in
bazelbuild/bazel-worker-api, I had to roll my own new
`workspace_compat()` macro. This macro creates
`@bazel_worker_{api,java}` repos from the `bazel-worker-api` archive
using @Wyverald's `http_archive` and `strip_prefix` suggestion
from bazel-contrib#1756.

Regarding `--incompatible_autoload_externally`, I'd added it in bazel-contrib#1748
when fixing problems with `WORKSPACE` builds under Bazel 8.2.1. However,
it's not really necessary, so I removed it.
mbland added a commit to mbland/rules_scala that referenced this pull request Aug 5, 2025
Uses the `bazel_worker_java` module and a legacy `WORKSPACE` shim to
replace `@bazel_tools//src/main/protobuf:worker_protocol_java_proto`.
This, and bumping `rules_java` to 8.14.0, fixes breakages in the latest
`last_green` Bazel from commit 00b48b27aa216befc419e540919a1f1df4cda337.

Note, though, that this change bumps `rules_java` to 8.15.0, since it's
now available. This change also updates:

- `gazelle`: 0.44.0 => 0.45.0
- `rules_go`: 0.55.1 => 0.56.1
- `rules_shell`: 0.5.0 => 0.5.1

Also:

- Removes the `--incompatible_autoload_externally` flag from `.bazelrc`.

- Removes the Bazel 9.0.0-pre.20250710.1 CI job added by bazel-contrib#1755, since
  it's no longer necessary given the fix from this change.

- Fixes `_get_compiler_srcjar` to return empty `compiler_srcjar_objects`
  instead of returning a valid object. `test_compiler_srcjar_error
  2.12.11` from `dt_patches/dt_patch_test.sh` caught this under
  `WORKSPACE`. Added `test_fail_if_compiler_srcjar_object_is_empty` to
  `test/shell/test_compiler_sources_integrity.sh` to catch the specific
  problem sooner.

- Fixed regex in `target_file_location` from `test_helper.sh` to work
  with Bazel 6.5.0, and fixed unbound variable in `fail` message.

- Added logic to `teardown_suite` in `test_bzlmod_macros.sh` to avoid
  unbound variable breakage when running under Bazel 6.5.0.

- Added logic to skip `test_check_module_bazel_template` under Bazel 6
  in `test_version.sh`.

- Removed restriction to use `protobuf` v29 or lower with Bazel 6 from
  `README.md`.

- Added `scala_compiler_source.*` to the regular expressions for "canonical
  reproducible" messages in `dt_patches/dt_patch_test.sh`. This resolved
  a test breakage when `rules_python` began to emit a "canonical
  reproducible" message. (Also changed `--expunge` to
  `--expunge_async`.)

---

bazelbuild/bazel#26477, which also landed in the 9.0.0-pre.20250714.1
rolling release, broke the `last_green` build:

```
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.
```

The failing target, and several others, depended upon
`@bazel_tools//src/main/protobuf:worker_protocol_java_proto`. Nothing
else depends on any other target from that package. So upon @Wyverald's
advice, I attempted to use the `bazel_worker_java` module to replace
this specific dependency:

- bazelbuild/bazel#26579 (comment)

The next failure was due to `rules_scala` overriding `rules_java` to be
8.12.0, whereas `last_green` now requires 8.14.0:

```txt
$ USE_BAZEL_VERSION=last_green bazel build //src/... //test/...

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  in java_library rule //src/java/io/bazel/rulesscala/jar:jar:
  Traceback (most recent call last):
    File ".../external/rules_java+/java/bazel/rules/bazel_java_library.bzl",
      line 26, column 35, in _proxy
        return bazel_java_library_rule(
    File ".../external/rules_java+/java/common/rules/impl/bazel_java_library_impl.bzl",
      line 68, column 43, in bazel_java_library_rule
        target, base_info = basic_java_library(
    File ".../external/rules_java+/java/common/rules/impl/basic_java_library_impl.bzl",
      line 127, column 49, in basic_java_library
        java_info, compilation_info = compile_action(
    File ".../external/rules_java+/java/common/rules/impl/compile_action.bzl",
      line 139, column 46, in compile_action
        java_info = _compile_private_for_builtins(
    File ".../external/rules_java+/java/private/java_common_internal.bzl",
      line 217, column 68, in compile
        get_internal_java_common().create_header_compilation_action(

Error in create_header_compilation_action:
  create_header_compilation_action() missing 2 required positional
  arguments: header_compilation_jar, header_compilation_direct_deps

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  Analysis of target '//src/java/io/bazel/rulesscala/jar:jar' failed
```

Bumping `rules_java` to 8.14.0 in the `single_version_override` fixed
that.

Finally, since there's no legacy `WORKSPACE` API in
bazelbuild/bazel-worker-api, I had to roll my own new
`workspace_compat()` macro. This macro creates
`@bazel_worker_{api,java}` repos from the `bazel-worker-api` archive
using @Wyverald's `http_archive` and `strip_prefix` suggestion
from bazel-contrib#1756.

Regarding `--incompatible_autoload_externally`, I'd added it in bazel-contrib#1748
when fixing problems with `WORKSPACE` builds under Bazel 8.2.1. However,
it's not really necessary, so I removed it.
simuons pushed a commit to bazel-contrib/rules_scala that referenced this pull request Aug 10, 2025
* Fix last_green w/bazel_worker_java rules_java 8.15

Uses the `bazel_worker_java` module and a legacy `WORKSPACE` shim to
replace `@bazel_tools//src/main/protobuf:worker_protocol_java_proto`.
This, and bumping `rules_java` to 8.14.0, fixes breakages in the latest
`last_green` Bazel from commit 00b48b27aa216befc419e540919a1f1df4cda337.

Note, though, that this change bumps `rules_java` to 8.15.0, since it's
now available. This change also updates:

- `gazelle`: 0.44.0 => 0.45.0
- `rules_go`: 0.55.1 => 0.56.1
- `rules_shell`: 0.5.0 => 0.5.1

Also:

- Removes the `--incompatible_autoload_externally` flag from `.bazelrc`.

- Removes the Bazel 9.0.0-pre.20250710.1 CI job added by #1755, since
  it's no longer necessary given the fix from this change.

- Fixes `_get_compiler_srcjar` to return empty `compiler_srcjar_objects`
  instead of returning a valid object. `test_compiler_srcjar_error
  2.12.11` from `dt_patches/dt_patch_test.sh` caught this under
  `WORKSPACE`. Added `test_fail_if_compiler_srcjar_object_is_empty` to
  `test/shell/test_compiler_sources_integrity.sh` to catch the specific
  problem sooner.

- Fixed regex in `target_file_location` from `test_helper.sh` to work
  with Bazel 6.5.0, and fixed unbound variable in `fail` message.

- Added logic to `teardown_suite` in `test_bzlmod_macros.sh` to avoid
  unbound variable breakage when running under Bazel 6.5.0.

- Added logic to skip `test_check_module_bazel_template` under Bazel 6
  in `test_version.sh`.

- Removed restriction to use `protobuf` v29 or lower with Bazel 6 from
  `README.md`.

- Added `scala_compiler_source.*` to the regular expressions for "canonical
  reproducible" messages in `dt_patches/dt_patch_test.sh`. This resolved
  a test breakage when `rules_python` began to emit a "canonical
  reproducible" message. (Also changed `--expunge` to
  `--expunge_async`.)

---

bazelbuild/bazel#26477, which also landed in the 9.0.0-pre.20250714.1
rolling release, broke the `last_green` build:

```
$ USE_BAZEL_VERSION=9.0.0-pre.20250714.1 bazel test //src/... //test/...

ERROR: error loading package '@@bazel_tools//src/main/protobuf':
  Unable to find package for
  @@[unknown repo 'grpc-java' requested from @@bazel_tools]//:java_grpc_library.bzl:

  The repository '@@[unknown repo 'grpc-java' requested from @@bazel_tools]'
  could not be resolved:
  No repository visible as '@grpc-java' from repository '@@bazel_tools'.
```

The failing target, and several others, depended upon
`@bazel_tools//src/main/protobuf:worker_protocol_java_proto`. Nothing
else depends on any other target from that package. So upon @Wyverald's
advice, I attempted to use the `bazel_worker_java` module to replace
this specific dependency:

- bazelbuild/bazel#26579 (comment)

The next failure was due to `rules_scala` overriding `rules_java` to be
8.12.0, whereas `last_green` now requires 8.14.0:

```txt
$ USE_BAZEL_VERSION=last_green bazel build //src/... //test/...

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  in java_library rule //src/java/io/bazel/rulesscala/jar:jar:
  Traceback (most recent call last):
    File ".../external/rules_java+/java/bazel/rules/bazel_java_library.bzl",
      line 26, column 35, in _proxy
        return bazel_java_library_rule(
    File ".../external/rules_java+/java/common/rules/impl/bazel_java_library_impl.bzl",
      line 68, column 43, in bazel_java_library_rule
        target, base_info = basic_java_library(
    File ".../external/rules_java+/java/common/rules/impl/basic_java_library_impl.bzl",
      line 127, column 49, in basic_java_library
        java_info, compilation_info = compile_action(
    File ".../external/rules_java+/java/common/rules/impl/compile_action.bzl",
      line 139, column 46, in compile_action
        java_info = _compile_private_for_builtins(
    File ".../external/rules_java+/java/private/java_common_internal.bzl",
      line 217, column 68, in compile
        get_internal_java_common().create_header_compilation_action(

Error in create_header_compilation_action:
  create_header_compilation_action() missing 2 required positional
  arguments: header_compilation_jar, header_compilation_direct_deps

ERROR: src/java/io/bazel/rulesscala/jar/BUILD:3:13:
  Analysis of target '//src/java/io/bazel/rulesscala/jar:jar' failed
```

Bumping `rules_java` to 8.14.0 in the `single_version_override` fixed
that.

Finally, since there's no legacy `WORKSPACE` API in
bazelbuild/bazel-worker-api, I had to roll my own new
`workspace_compat()` macro. This macro creates
`@bazel_worker_{api,java}` repos from the `bazel-worker-api` archive
using @Wyverald's `http_archive` and `strip_prefix` suggestion
from #1756.

Regarding `--incompatible_autoload_externally`, I'd added it in #1748
when fixing problems with `WORKSPACE` builds under Bazel 8.2.1. However,
it's not really necessary, so I removed it.

* Update Maven artifact versions

- Scalafmt: 3.9.8 => 3.9.9
- `grpc`: 1.73.0 => 1.74.0
- `proto-google-common-protos`: 2.59.2 => 2.60.0
- `sbt-util-interface`: 1.11.3 => 1.11.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants