From cd22d8896f209c37be8622f1dcc9770c2dc18f48 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Tue, 8 Oct 2024 04:30:17 -0400 Subject: [PATCH] Bazel 7 compatibility updates (#1619) * Add toolchain_type to thrift_lib, scrooge aspects This fixes the following error: ```txt Error in create_header_compilation_action: Rule 'thrift_library' in 'rules_scala/test/src/main/scala/scalarules/test/twitter_scrooge/thrift/ thrift_with_compiler_args/BUILD:3:15' must declare '@@bazel_tools//tools/jdk:toolchain_type' toolchain in order to use java_common. See https://github.com/bazelbuild/bazel/issues/18970. ``` Interestingly, adding the toolchain type to `thrift_library` isn't enough; I had to add it to the twitter_scrooge aspects as well. Until I did, it produced the same error message pointing at `thrift_library`, after first reporting: ```txt ERROR: rules_scala/test/src/main/scala/scalarules/test/twitter_scrooge/ thrift/thrift_with_compiler_args/BUILD:3:15: in //twitter_scrooge:twitter_scrooge.bzl%scrooge_java_aspect aspect on thrift_library rule //test/src/main/scala/scalarules/test/twitter_scrooge/thrift/ thrift_with_compiler_args:thrift5: Traceback (most recent call last): File "rules_scala/twitter_scrooge/twitter_scrooge.bzl", line 420, column 49, in _scrooge_java_aspect_impl return _common_scrooge_aspect_implementation(target, ctx, "java", _compile_generated_java) [ ...snip... ] ``` * Fix proto_cross_repo_boundary build_file attribute Bazel 7 enforces that this be a proper target label, not a relative path. ```txt ERROR: WORKSPACE:91:37: fetching new_local_repository rule //external:proto_cross_repo_boundary: .../external/test/proto_cross_repo_boundary/repo/BUILD.repo is not a regular file; if you're using a relative or absolute path for `build_file` in your `new_local_repository` rule, please switch to using a label instead INFO: Repository remote_jdk8_macos instantiated at: WORKSPACE:175:18: in .../external/rules_java/java/repositories.bzl:120:10: in remote_jdk8_repos .../external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe .../external/rules_java/toolchains/remote_java_repository.bzl:48:17: in remote_java_repository Repository rule http_archive defined at: .../external/bazel_tools/tools/build_defs/repo/http.bzl:384:31: in ERROR: no such package '@@proto_cross_repo_boundary//': .../external/test/proto_cross_repo_boundary/repo/BUILD.repo is not a regular file; if you're using a relative or absolute path for `build_file` in your `new_local_repository` rule, please switch to using a label instead ERROR: test/proto_cross_repo_boundary/BUILD:3:22: //test/proto_cross_repo_boundary:sample_scala_proto depends on @@proto_cross_repo_boundary//:sample_proto in repository @@proto_cross_repo_boundary which failed to fetch. no such package '@@proto_cross_repo_boundary//': .../external/test/proto_cross_repo_boundary/repo/BUILD.repo is not a regular file; if you're using a relative or absolute path for `build_file` in your `new_local_repository` rule, please switch to using a label instead Use --verbose_failures to see the command lines of failed build steps. ERROR: Analysis of target '//test/proto_cross_repo_boundary:sample_scala_proto' failed; build aborted: Analysis failed ``` * Add rules_python stanza to WORKSPACE files Fixes the following breakages under Bazel 7: ```txt $ bazel build //src/... ERROR: error loading package '@@bazel_tools//src/main/protobuf': cannot load '@@rules_python//python:proto.bzl': no such file ERROR: .../src/java/io/bazel/rulesscala/coverage/instrumenter/BUILD:3:12: error loading package '@@bazel_tools//src/main/protobuf': cannot load '@@rules_python//python:proto.bzl': no such file and referenced by '//src/java/io/bazel/rulesscala/coverage/instrumenter:instrumenter' ``` * Set --noenable_bzlmod to prevent MODULE.bazel Makes sure Bazel doesn't autogenerate MODULE.bazel and MODULE.bazel.lock files for now. * Update to Bazel 6.5.0 This is the last release in the Bazel 6 line. With the changes up to this point, the Bazel 7 build only fails on protobuf generation, e.g. on `bazel build //test/proto3:all`, as seen below. Bumping to Bazel 6.5.0 on top of all the previous changes isolates the Bazel 7.0.0 changes causing the failure. ```txt $ bazel build //test/proto3:all ERROR: .../rules_scala/test/proto3/BUILD:14:14: ProtoScalaPBRule test/proto3/generated-proto-lib_jvm_extra_protobuf_generator_scalapb.srcjar failed: (Exit 1): scalapb_worker failed: error executing ProtoScalaPBRule command (from target //test/proto3:generated-proto-lib) bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/src/scala/scripts/scalapb_worker ... (remaining 2 arguments skipped) Could not find file in descriptor database: bazel-out/darwin_arm64-fastbuild/bin/test/proto3/generated.proto: No such file or directory java.lang.RuntimeException: Exit with code 1 at scala.sys.package$.error(package.scala:30) at scripts.ScalaPBWorker$.work(ScalaPBWorker.scala:44) at io.bazel.rulesscala.worker.Worker.persistentWorkerMain(Worker.java:96) at io.bazel.rulesscala.worker.Worker.workerMain(Worker.java:49) at scripts.ScalaPBWorker$.main(ScalaPBWorker.scala:39) at scripts.ScalaPBWorker.main(ScalaPBWorker.scala) Use --verbose_failures to see the command lines of failed build steps. ERROR: .../rules_scala/test/proto3/BUILD:14:14 scala @//test/proto3:generated-proto-lib failed: (Exit 1): scalapb_worker failed: error executing ProtoScalaPBRule command (from target //test/proto3:generated-proto-lib) bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/src/scala/scripts/scalapb_worker ... (remaining 2 arguments skipped) ``` * Fix WORKSPACE lint errors One of these days I'll remember to run `bazel run //tools:lint_fix` before opening a pull request. * Set --enable_workspace on last_green CI build Learning more about BuildKite every day. * Allow test_all.sh to pass under Bazel 7 `bash ./test_all.sh` passes after minor updates to the following test cases to handle slightly different behavior under Bazel 7: - `test_custom_reporter_class_has_been_set` makes the test output dir writable, since it no longer is by default. - `test_scala_import_expect_failure_on_missing_direct_deps_warn_mode` removes preexisting output, since Bazel 7 won't emit warnings if it already exists. --- FYI: Under Bazel 7.0 and Bazel 7.1, buildifier warnings for external targets in the following test cases changed to begin with `@@repo_name` instead of `@repo_name`: - test/shell/test_scala_library.sh: `test_scala_library_expect_failure_on_missing_direct_external_deps_jar` `test_scala_library_expect_failure_on_missing_direct_external_deps_file_group` - test/shell/test_strict_dependency.sh: `test_stamped_target_label_loading` `test_strict_deps_filter_included_target` - test/shell/test_test_unused_dependency.sh: `test_unused_deps_filter_included_target` However, as of Bazel 7.2, those warnings changed back to `@repo_name`, so those changes aren't reflected in this commit. * Bump to rules_go 0.39.1 for Bazel 7 compatibility `bazel run //tools:lint_{check,fix}` required updating rules_go to 0.39.1 to work under Bazel 7. The previous rules_go version 0.38.1 caused the following error: ```txt $ ./test_lint.sh ERROR: .../external/io_bazel_rules_go/BUILD.bazel:71:16: in (an implicit dependency) attribute of go_context_data rule @@io_bazel_rules_go//:go_context_data: in $whitelist_function_transition attribute of go_context_data rule @@io_bazel_rules_go//:go_context_data: package group '@@bazel_tools//tools/whitelists/function_transition_whitelist:function_transition_whitelist' is misplaced here (they are only allowed in the visibility attribute) ERROR: .../external/io_bazel_rules_go/BUILD.bazel:71:16: Analysis of target '@@io_bazel_rules_go//:go_context_data' failed ERROR: Analysis of target '//tools:lint_check' failed; build aborted: Analysis failed ``` * Bump to rules_java 7.9.0 for Bazel 7 compatibility Updated rules_java to 7.9.0 to fix errors of the following type under Bazel 7.2.1: ```txt ERROR: test/BUILD:640:10: While resolving toolchains for target //test:jar_lister (096dcc8): invalid registered toolchain '@remote_jdk8_linux_aarch64_toolchain_config_repo//:bootstrap_runtime_toolchain': no such target '@@remote_jdk8_linux_aarch64_toolchain_config_repo//:bootstrap_runtime_toolchain': target 'bootstrap_runtime_toolchain' not declared in package '' defined by .../external/remote_jdk8_linux_aarch64_toolchain_config_repo/BUILD.bazel ERROR: Analysis of target '//test:jar_lister' failed; build aborted ``` Also removed the seemingly unused `rules_java_extra` stanza from `WORKSPACE`. --- Though `rules_java` version 7.12.1 is available, and largely works with this repo when using Bazel 7.3.2, it requires a few temporary workarounds. (As I write this, 8.0.0 came out just a few hours ago and I haven't tried it.) Rather than commit the workarounds, upgrading only to 7.9.0 now seems less crufty. Though this commit only updates Bazel to 7.2.1, I suspect it's probably the same basic problem at play. What follows is a very detailed explanation of what happens with 7.12.1 with Bazel 7.3.2, just to have it on the record. --- The workaround is to change a few toolchain and macro file targets from `@bazel_tools//tools/jdk:` to `@rules_java//toolchains:`. This isn't a terribly bad or invasive workaround, but `@bazel_tools//tools/jdk:` is clearly the canonical path. Best to keep it that way, lest we build up technical debt. Without the workaround, these targets would fail: - //test/src/main/resources/java_sources:CompiledWithJava11 - //test/src/main/resources/java_sources:CompiledWithJava8 - //test/toolchains:java21_toolchain - //test:JunitRuntimePlatform - //test:JunitRuntimePlatform_test_runner - //test:scala_binary_jdk_11 with this error: ```txt ERROR: .../external/rules_java_builtin/toolchains/BUILD:254:14: While resolving toolchains for target @@rules_java_builtin//toolchains:platformclasspath (096dcc8): No matching toolchains found for types @@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type. ``` This appears to be a consequence of both upgrading the Bazel version to 7.3.2 and updating `rules_java` to 7.12.1. The `rules_java_builtin` repo is part of the `WORKSPACE` prefix that adds implicit dependencies: - https://bazel.build/external/migration#builtin-default-deps This repo was added to 7.0.0-pre.20231011.2 in the following change, mapped to `@rules_java` within the scope of the `@bazel_tools` repo: - bazelbuild/bazel: Add rules_java_builtin to the users of Java modules https://github.com/bazelbuild/bazel/commit/ff1abb29a20c91a3d797842a26fb8a6b6fac48d8 This change tried to ensure `rules_java` remained compatible with earlier Bazel versions. However, it changed all instances of `@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type` to `//toolchains:bootstrap_runtime_toolchain_type`: - bazelbuild/rules_java: Make rules_java backwards compatible with Bazel 6.3.0 https://github.com/bazelbuild/rules_java/commit/30ecf3ff6ee8f30b4df505d9d3bde5bb1c25690b Bazel has bumped `rules_java` in its `workspace_deps.bzl` from 7.9.0 to 7.11.0, but it's only available as of 8.0.0-pre.20240911.1. - bazelbuild/bazel: Update rules_java 7.11.1 / java_tools 13.8 https://github.com/bazelbuild/bazel/pull/23571 https://github.com/bazelbuild/bazel/commit/f92124acf3d0eb99d06570ddc380aca7ab354b90 --- What I believe is happening is, under Bazel 7.3.2 and `rules_java` 7.12.1: - Bazel creates `rules_java` 7.9.0 as `@rules_java_builtin` in the `WORKSPACE` prefix. - `@bazel_tools` has `@rules_java` mapped to `@rules_java_builtin` when initialized during the `WORKSPACE` prefix, during which `@bazel_tools//tools/jdk` registers `alias()` targets to `@rules_java` toolchain targets. These aliased toolchains specify `@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type` in their `toolchains` attribute. - `WORKSPACE` loads `@rules_java` 7.12.1 and registers all its toolchains with type `@rules_java//toolchains:bootstrap_runtime_toolchain_type`. - Some `@rules_java` rules explicitly specifying toolchains from `@bazel_tools//tools/jdk` can't find them, because the `@bazel_tools//tools/jdk` toolchain aliases expect toolchains of type `@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type`. This has broken other projects in the same way: - bazelbuild/bazel: [Bazel CI] Downstream project broken by rules_java upgrade #23619 https://github.com/bazelbuild/bazel/issues/23619 These problems don't appear under Bzlmod, whereby `@rules_java_builtin` was never required. This is because `WORKSPACE` executes its statements sequentially, while Bzlmod builds the module dependency graph _before_ instantiating repositories (within module extensions). It seems a fix is on the way that removes `@rules_java_builtin` from the `WORKSPACE` prefix, and adds `@rules_java` to the suffix. At this moment, though, it's not even in a prerelease: - bazelbuild/bazel: Remove rules_java_builtin in WORKSPACE prefix https://github.com/bazelbuild/bazel/commit/750669078e20f2c6ca7b9241e1c80564a1b8668e --- Note that the error message matches that from the following resolved issue, but that issue was for non-Bzlmod child repos when `WORKSPACE` was disabled. - bazelbuild/bazel: Undefined @@rules_java_builtin repository with --noenable_workspace option https://github.com/bazelbuild/bazel/issues/22754 --- .bazelci/presubmit.yml | 13 ++++---- .bazelrc | 4 +++ .bazelversion | 2 +- WORKSPACE | 30 +++++++++---------- dt_patches/test_dt_patches/WORKSPACE | 11 +++++++ .../test_dt_patches_user_srcjar/WORKSPACE | 11 +++++++ examples/crossbuild/.bazelrc | 3 ++ examples/crossbuild/WORKSPACE | 11 +++++++ examples/scala3/.bazelrc | 3 ++ examples/scala3/WORKSPACE | 11 +++++++ examples/semanticdb/.bazelrc | 3 ++ examples/semanticdb/WORKSPACE | 11 +++++++ .../multi_frameworks_toolchain/.bazelrc | 4 +++ .../multi_frameworks_toolchain/WORKSPACE | 11 +++++++ .../testing/scalatest_repositories/.bazelrc | 3 ++ .../testing/scalatest_repositories/WORKSPACE | 11 +++++++ .../specs2_junit_repositories/.bazelrc | 6 +++- .../specs2_junit_repositories/WORKSPACE | 11 +++++++ scala/private/macros/scala_repositories.bzl | 4 +-- scala/private/rules/scala_repl.bzl | 5 +++- test/proto_cross_repo_boundary/repo.bzl | 2 +- test/shell/test_custom_reporter_class.sh | 3 +- test/shell/test_strict_dependency.sh | 3 ++ test_cross_build/.bazelrc | 3 ++ test_cross_build/WORKSPACE | 11 +++++++ test_version/.bazelrc | 3 ++ test_version/WORKSPACE.template | 11 +++++++ .../test/example_external_workspace/.bazelrc | 3 ++ .../test/example_external_workspace/WORKSPACE | 11 +++++++ third_party/test/proto/.bazelrc | 3 ++ third_party/test/proto/WORKSPACE | 11 +++++++ thrift/thrift.bzl | 1 + tools/bazel.rc.buildkite | 4 +++ twitter_scrooge/twitter_scrooge.bzl | 21 +++++++------ 34 files changed, 220 insertions(+), 38 deletions(-) create mode 100644 examples/crossbuild/.bazelrc create mode 100644 examples/scala3/.bazelrc create mode 100644 examples/semanticdb/.bazelrc create mode 100644 examples/testing/scalatest_repositories/.bazelrc create mode 100644 test_cross_build/.bazelrc create mode 100644 test_version/.bazelrc create mode 100644 third_party/test/example_external_workspace/.bazelrc create mode 100644 third_party/test/proto/.bazelrc diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 7556ffcb6..227119b03 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -36,6 +36,7 @@ tasks: shell_commands: # Install xmllint - sudo apt update && sudo apt install --reinstall libxml2-utils -y + - echo "build --enable_workspace" >> .bazelrc - "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with latest Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\"" test_rules_scala_macos: name: "./test_rules_scala" @@ -47,16 +48,16 @@ tasks: platform: windows shell_commands: - "bash test_rules_scala.sh" - test_coverage_linux_6_3_0: + test_coverage_linux_6_5_0: name: "./test_coverage" platform: ubuntu2004 - bazel: 6.3.0 + bazel: 6.5.0 shell_commands: - "./test_coverage.sh" - test_coverage_macos_6.3.0: + test_coverage_macos_6.5.0: name: "./test_coverage" platform: macos - bazel: 6.3.0 + bazel: 6.5.0 shell_commands: - "./test_coverage.sh" test_reproducibility_linux: @@ -82,13 +83,13 @@ tasks: examples_linux: name: "./test_examples" platform: ubuntu2004 - bazel: 6.3.0 + bazel: 6.5.0 shell_commands: - "./test_examples.sh" cross_build_linux: name: "./test_cross_build" platform: ubuntu2004 - bazel: 6.3.0 + bazel: 6.5.0 shell_commands: - "./test_cross_build.sh" lint_linux: diff --git a/.bazelrc b/.bazelrc index b37b4dc55..498871943 100644 --- a/.bazelrc +++ b/.bazelrc @@ -3,3 +3,7 @@ build --enable_platform_specific_config #Windows needs --worker_quit_after_build due to workers not being shut down when the compiler tools need to be rebuilt (resulting in 'file in use' errors). See Bazel Issue#10498. build:windows --worker_quit_after_build --enable_runfiles + +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/.bazelversion b/.bazelversion index 798e38995..f22d756da 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.3.0 +6.5.0 diff --git a/WORKSPACE b/WORKSPACE index 44de58fe5..08eb52097 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,6 +15,17 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + _build_tools_release = "5.1.0" http_archive( @@ -127,10 +138,10 @@ format_repositories() http_archive( name = "io_bazel_rules_go", - sha256 = "dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d", + sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", ], ) @@ -144,19 +155,6 @@ go_rules_dependencies() go_register_toolchains(version = "1.19.5") -# Explicitly pull in a different (newer) version of rules_java for remote jdks -rules_java_extra_version = "5.1.0" - -rules_java_extra_sha = "d974a2d6e1a534856d1b60ad6a15e57f3970d8596fbb0bb17b9ee26ca209332a" - -rules_java_extra_url = "https://github.com/bazelbuild/rules_java/releases/download/{}/rules_java-{}.tar.gz".format(rules_java_extra_version, rules_java_extra_version) - -http_archive( - name = "rules_java_extra", - sha256 = rules_java_extra_sha, - url = rules_java_extra_url, -) - load("@rules_java//java:repositories.bzl", "remote_jdk8_repos") # We need to select based on platform when we use these diff --git a/dt_patches/test_dt_patches/WORKSPACE b/dt_patches/test_dt_patches/WORKSPACE index f4bf9680c..01ddd7181 100644 --- a/dt_patches/test_dt_patches/WORKSPACE +++ b/dt_patches/test_dt_patches/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../..", diff --git a/dt_patches/test_dt_patches_user_srcjar/WORKSPACE b/dt_patches/test_dt_patches_user_srcjar/WORKSPACE index 92af9eaac..3428f472f 100644 --- a/dt_patches/test_dt_patches_user_srcjar/WORKSPACE +++ b/dt_patches/test_dt_patches_user_srcjar/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../..", diff --git a/examples/crossbuild/.bazelrc b/examples/crossbuild/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/examples/crossbuild/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/examples/crossbuild/WORKSPACE b/examples/crossbuild/WORKSPACE index 4711fc376..ff01165d1 100644 --- a/examples/crossbuild/WORKSPACE +++ b/examples/crossbuild/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../..", diff --git a/examples/scala3/.bazelrc b/examples/scala3/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/examples/scala3/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/examples/scala3/WORKSPACE b/examples/scala3/WORKSPACE index 07933b4b7..b1864f4ed 100644 --- a/examples/scala3/WORKSPACE +++ b/examples/scala3/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../..", diff --git a/examples/semanticdb/.bazelrc b/examples/semanticdb/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/examples/semanticdb/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/examples/semanticdb/WORKSPACE b/examples/semanticdb/WORKSPACE index 99b58d10b..d9324f8c1 100644 --- a/examples/semanticdb/WORKSPACE +++ b/examples/semanticdb/WORKSPACE @@ -14,6 +14,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../..", diff --git a/examples/testing/multi_frameworks_toolchain/.bazelrc b/examples/testing/multi_frameworks_toolchain/.bazelrc index 6cd4a6699..46e8bdec7 100644 --- a/examples/testing/multi_frameworks_toolchain/.bazelrc +++ b/examples/testing/multi_frameworks_toolchain/.bazelrc @@ -1,2 +1,6 @@ build --enable_platform_specific_config windows:build --enable_runfiles + +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/examples/testing/multi_frameworks_toolchain/WORKSPACE b/examples/testing/multi_frameworks_toolchain/WORKSPACE index ea4eb2f35..8070f0a0d 100644 --- a/examples/testing/multi_frameworks_toolchain/WORKSPACE +++ b/examples/testing/multi_frameworks_toolchain/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../../..", diff --git a/examples/testing/scalatest_repositories/.bazelrc b/examples/testing/scalatest_repositories/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/examples/testing/scalatest_repositories/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/examples/testing/scalatest_repositories/WORKSPACE b/examples/testing/scalatest_repositories/WORKSPACE index 546f9e00b..e5a2a0790 100644 --- a/examples/testing/scalatest_repositories/WORKSPACE +++ b/examples/testing/scalatest_repositories/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../../..", diff --git a/examples/testing/specs2_junit_repositories/.bazelrc b/examples/testing/specs2_junit_repositories/.bazelrc index 80890a133..46e8bdec7 100644 --- a/examples/testing/specs2_junit_repositories/.bazelrc +++ b/examples/testing/specs2_junit_repositories/.bazelrc @@ -1,2 +1,6 @@ build --enable_platform_specific_config -windows:build --enable_runfiles \ No newline at end of file +windows:build --enable_runfiles + +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/examples/testing/specs2_junit_repositories/WORKSPACE b/examples/testing/specs2_junit_repositories/WORKSPACE index 3d67bf00d..1a2dfb287 100644 --- a/examples/testing/specs2_junit_repositories/WORKSPACE +++ b/examples/testing/specs2_junit_repositories/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../../..", diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index e11f199d5..204fd5629 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -104,9 +104,9 @@ def rules_scala_setup(scala_compiler_srcjar = None): http_archive( name = "rules_java", urls = [ - "https://github.com/bazelbuild/rules_java/releases/download/5.4.1/rules_java-5.4.1.tar.gz", + "https://github.com/bazelbuild/rules_java/releases/download/7.9.0/rules_java-7.9.0.tar.gz", ], - sha256 = "a1f82b730b9c6395d3653032bd7e3a660f9d5ddb1099f427c1e1fe768f92e395", + sha256 = "41131de4417de70b9597e6ebd515168ed0ba843a325dc54a81b92d7af9a7b3ea", ) if not native.existing_rule("rules_proto"): diff --git a/scala/private/rules/scala_repl.bzl b/scala/private/rules/scala_repl.bzl index 6d08c8b84..49586da79 100644 --- a/scala/private/rules/scala_repl.bzl +++ b/scala/private/rules/scala_repl.bzl @@ -81,7 +81,10 @@ def make_scala_repl(*extras): common_outputs, *[extra["outputs"] for extra in extras if "outputs" in extra] ), - toolchains = ["@io_bazel_rules_scala//scala:toolchain_type"], + toolchains = [ + "@io_bazel_rules_scala//scala:toolchain_type", + "@bazel_tools//tools/jdk:toolchain_type", + ], cfg = scala_version_transition, incompatible_use_toolchain_transition = True, implementation = _scala_repl_impl, diff --git a/test/proto_cross_repo_boundary/repo.bzl b/test/proto_cross_repo_boundary/repo.bzl index 0f19c06d2..fe3fecf04 100644 --- a/test/proto_cross_repo_boundary/repo.bzl +++ b/test/proto_cross_repo_boundary/repo.bzl @@ -2,5 +2,5 @@ def proto_cross_repo_boundary_repository(): native.new_local_repository( name = "proto_cross_repo_boundary", path = "test/proto_cross_repo_boundary/repo", - build_file = "test/proto_cross_repo_boundary/repo/BUILD.repo", + build_file = "//test/proto_cross_repo_boundary:repo/BUILD.repo", ) diff --git a/test/shell/test_custom_reporter_class.sh b/test/shell/test_custom_reporter_class.sh index f0985db16..3daa04a01 100644 --- a/test/shell/test_custom_reporter_class.sh +++ b/test/shell/test_custom_reporter_class.sh @@ -22,9 +22,10 @@ test_custom_reporter_class_has_been_set() { bazel test test/scala_test:custom_reporter set +e reporter_output_dir="$(bazel info bazel-testlogs)/test/scala_test/custom_reporter/test.outputs" + chmod u+w "$reporter_output_dir" # Needed under Bazel 7 reporter_output_filepath="${reporter_output_dir}/${custom_reporter_check_file}" unzip -oq "${reporter_output_dir}/outputs.zip" -d "${reporter_output_dir}" assert_file_exists "${reporter_output_filepath}" } -$runner test_custom_reporter_class_has_been_set \ No newline at end of file +$runner test_custom_reporter_class_has_been_set diff --git a/test/shell/test_strict_dependency.sh b/test/shell/test_strict_dependency.sh index da6537815..01a0d4029 100755 --- a/test/shell/test_strict_dependency.sh +++ b/test/shell/test_strict_dependency.sh @@ -21,6 +21,9 @@ test_scala_import_expect_failure_on_missing_direct_deps_warn_mode() { dependency_target2='//test_expect_failure/scala_import:guava' test_target='test_expect_failure/scala_import:scala_import_propagates_compile_deps' + # Bazel 7 won't emit warnings if the output already exists. + rm -f "$(bazel info bazel-bin)/${test_target/://}"* + local expected_message1="buildozer 'add deps $dependency_target1' //$test_target" local expected_message2="buildozer 'add deps $dependency_target2' //$test_target" diff --git a/test_cross_build/.bazelrc b/test_cross_build/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/test_cross_build/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/test_cross_build/WORKSPACE b/test_cross_build/WORKSPACE index 1dc58574c..01f22da1c 100644 --- a/test_cross_build/WORKSPACE +++ b/test_cross_build/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + http_archive( name = "rules_proto", sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", diff --git a/test_version/.bazelrc b/test_version/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/test_version/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/test_version/WORKSPACE.template b/test_version/WORKSPACE.template index 34c499f2f..741f349e1 100644 --- a/test_version/WORKSPACE.template +++ b/test_version/WORKSPACE.template @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + http_archive( name = "rules_proto", sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", diff --git a/third_party/test/example_external_workspace/.bazelrc b/third_party/test/example_external_workspace/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/third_party/test/example_external_workspace/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/third_party/test/example_external_workspace/WORKSPACE b/third_party/test/example_external_workspace/WORKSPACE index 43ab12468..f065d65ba 100644 --- a/third_party/test/example_external_workspace/WORKSPACE +++ b/third_party/test/example_external_workspace/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../../..", diff --git a/third_party/test/proto/.bazelrc b/third_party/test/proto/.bazelrc new file mode 100644 index 000000000..100128b44 --- /dev/null +++ b/third_party/test/proto/.bazelrc @@ -0,0 +1,3 @@ +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/third_party/test/proto/WORKSPACE b/third_party/test/proto/WORKSPACE index 192e6f4ab..e3f4bc4af 100644 --- a/third_party/test/proto/WORKSPACE +++ b/third_party/test/proto/WORKSPACE @@ -11,6 +11,17 @@ http_archive( ], ) +http_archive( + name = "rules_python", + sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", + strip_prefix = "rules_python-0.36.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + local_repository( name = "io_bazel_rules_scala", path = "../../../", diff --git a/thrift/thrift.bzl b/thrift/thrift.bzl index dacd1050c..350c05bed 100644 --- a/thrift/thrift.bzl +++ b/thrift/thrift.bzl @@ -178,4 +178,5 @@ thrift_library = rule( }, outputs = {"libarchive": "lib%{name}.jar"}, provides = [ThriftInfo], + toolchains = ["@bazel_tools//tools/jdk:toolchain_type"], ) diff --git a/tools/bazel.rc.buildkite b/tools/bazel.rc.buildkite index 9d784856c..5126d6eaf 100644 --- a/tools/bazel.rc.buildkite +++ b/tools/bazel.rc.buildkite @@ -1 +1,5 @@ build --strategy=Scalac=worker --strategy=ScroogeRule=worker --worker_max_instances=3 + +# Remove upon completing Bzlmod compatibility work. +# - https://github.com/bazelbuild/rules_scala/issues/1482 +build --noenable_bzlmod diff --git a/twitter_scrooge/twitter_scrooge.bzl b/twitter_scrooge/twitter_scrooge.bzl index eae327a1f..1bdef6ecd 100644 --- a/twitter_scrooge/twitter_scrooge.bzl +++ b/twitter_scrooge/twitter_scrooge.bzl @@ -443,6 +443,12 @@ common_aspect_providers = [ [ScroogeImport], ] +common_toolchains = [ + "@io_bazel_rules_scala//scala:toolchain_type", + "@io_bazel_rules_scala//twitter_scrooge/toolchain:scrooge_toolchain_type", + "@bazel_tools//tools/jdk:toolchain_type", +] + scrooge_scala_aspect = aspect( implementation = _scrooge_scala_aspect_impl, attr_aspects = ["deps"], @@ -459,10 +465,7 @@ scrooge_scala_aspect = aspect( ), provides = [ScroogeAspectInfo], required_aspect_providers = common_aspect_providers, - toolchains = [ - "@io_bazel_rules_scala//scala:toolchain_type", - "@io_bazel_rules_scala//twitter_scrooge/toolchain:scrooge_toolchain_type", - ], + toolchains = common_toolchains, incompatible_use_toolchain_transition = True, ) @@ -477,10 +480,7 @@ scrooge_java_aspect = aspect( ), provides = [ScroogeAspectInfo], required_aspect_providers = common_aspect_providers, - toolchains = [ - "@io_bazel_rules_scala//scala:toolchain_type", - "@io_bazel_rules_scala//twitter_scrooge/toolchain:scrooge_toolchain_type", - ], + toolchains = common_toolchains, incompatible_use_toolchain_transition = True, fragments = ["java"], ) @@ -557,6 +557,9 @@ scrooge_scala_import = rule( ), }, provides = [ThriftInfo, JavaInfo, ScroogeImport], - toolchains = ["@io_bazel_rules_scala//twitter_scrooge/toolchain:scrooge_toolchain_type"], + toolchains = [ + "@io_bazel_rules_scala//twitter_scrooge/toolchain:scrooge_toolchain_type", + "@bazel_tools//tools/jdk:toolchain_type", + ], incompatible_use_toolchain_transition = True, )