diff --git a/.github/workflows/test_bazel.yml b/.github/workflows/test_bazel.yml index d7ef97c703f5..bf29c0121182 100644 --- a/.github/workflows/test_bazel.yml +++ b/.github/workflows/test_bazel.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: runner: [ ubuntu, windows, macos ] - bazelversion: [ '7.1.2' ] + bazelversion: [ '7.1.2', '8.0.0' ] bzlmod: [ true, false ] toolchain_resolution: [ "", "--incompatible_enable_proto_toolchain_resolution=true" ] runs-on: ${{ matrix.runner }}-latest @@ -58,4 +58,4 @@ jobs: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: examples version: ${{ matrix.bazelversion }} - bash: cd examples && bazel build //... $BAZEL_FLAGS --enable_bzlmod=${{ matrix.bzlmod }} ${{ matrix.toolchain_resolution }} + bash: cd examples && bazel build //... $BAZEL_FLAGS --subcommands --verbose_failures --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} ${{ matrix.toolchain_resolution }} diff --git a/MODULE.bazel b/MODULE.bazel index 970e4d99d7d1..088a7d65cb34 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,17 +13,17 @@ module( # https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution # Thus the highest version in their module graph is resolved. bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl") -bazel_dep(name = "bazel_skylib", version = "1.7.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "jsoncpp", version = "1.9.6") bazel_dep(name = "apple_support", version = "1.15.1", repo_name = "build_bazel_apple_support") -bazel_dep(name = "rules_cc", version = "0.0.16") +bazel_dep(name = "rules_cc", version = "0.0.17") bazel_dep(name = "rules_fuzzing", version = "0.5.2") -bazel_dep(name = "rules_java", version = "8.3.2") +bazel_dep(name = "rules_java", version = "8.6.1") bazel_dep(name = "rules_jvm_external", version = "6.3") bazel_dep(name = "rules_kotlin", version = "1.9.6") bazel_dep(name = "rules_license", version = "1.0.0") bazel_dep(name = "rules_pkg", version = "1.0.1") -bazel_dep(name = "rules_python", version = "0.28.0") +bazel_dep(name = "rules_python", version = "1.0.0") bazel_dep(name = "rules_rust", version = "0.51.0") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "zlib", version = "1.3.1") diff --git a/README.md b/README.md index ca1904b731fe..6b3b48c4d9c9 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,8 @@ bazel_dep(name = "protobuf", version = , repo_name = "com_google_protob Users can also add the following to their legacy [WORKSPACE](https://bazel.build/external/overview#workspace-system) file. -Note that the `protobuf_extra_deps.bzl` is added in the `v30.x` release. +Note that with the release of 30.x there are a few more load statements to +properly set up rules_java and rules_python. ``` http_archive( @@ -70,9 +71,17 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() -load("@com_google_protobuf//:protobuf_extra_deps.bzl", "protobuf_extra_deps") +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") -protobuf_extra_deps(); +rules_java_dependencies() + +load("@rules_java//java:repositories.bzl", "rules_java_toolchains") + +rules_java_toolchains() + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() ``` Protobuf Compiler Installation diff --git a/WORKSPACE b/WORKSPACE index 18b58e22f473..9155daa73b0e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,9 +20,13 @@ load("//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps") protobuf_deps() -load("//:protobuf_extra_deps.bzl", "protobuf_extra_deps") +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") -protobuf_extra_deps() +rules_java_dependencies() + +load("@rules_java//java:repositories.bzl", "rules_java_toolchains") + +rules_java_toolchains() load("@bazel_features//:deps.bzl", "bazel_features_deps") @@ -32,10 +36,6 @@ load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() -load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies") - -pip_install_dependencies() - # Bazel platform rules. http_archive( name = "platforms", @@ -102,12 +102,6 @@ load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependen apple_support_dependencies() -load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") - -rules_java_dependencies() - -rules_java_toolchains() - load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") rules_cc_dependencies() diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 820ea9f8cac3..2edbffde5c4f 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -6,8 +6,8 @@ local_path_override( path = "..", ) -bazel_dep(name = "bazel_skylib", version = "1.0.3") -bazel_dep(name = "rules_cc", version = "0.0.16") -bazel_dep(name = "rules_java", version = "8.3.2") -bazel_dep(name = "rules_pkg", version = "0.7.0") -bazel_dep(name = "rules_python", version = "0.25.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_cc", version = "0.0.17") +bazel_dep(name = "rules_java", version = "8.6.1") +bazel_dep(name = "rules_pkg", version = "1.0.1") +bazel_dep(name = "rules_python", version = "1.0.0") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 58c3eaeaae02..fd2a6a766fc3 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -1,7 +1,5 @@ workspace(name = "com_google_protobuf_examples") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - # This protobuf repository is required for proto_library rule. # It provides the protocol compiler binary (i.e., protoc). # @@ -28,19 +26,18 @@ local_repository( path = "..", ) -# Needed because protobuf_deps brings rules_python 0.26.0 which is broken: -# https://github.com/bazelbuild/rules_python/issues/1543 -http_archive( - name = "rules_python", - sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036", - strip_prefix = "rules_python-0.25.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz", -) - load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() -load("@com_google_protobuf//:protobuf_extra_deps.bzl", "protobuf_extra_deps") +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +load("@rules_java//java:repositories.bzl", "rules_java_toolchains") + +rules_java_toolchains() + +load("@rules_python//python:repositories.bzl", "py_repositories") -protobuf_extra_deps() +py_repositories() diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 0aadaaa26a19..d5d255bfdba4 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -15,9 +15,17 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() -load("@com_google_protobuf//:protobuf_extra_deps.bzl", "protobuf_extra_deps") +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") -protobuf_extra_deps(); +rules_java_dependencies() + +load("@rules_java//java:repositories.bzl", "rules_java_toolchains") + +rules_java_toolchains() + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() ``` """ @@ -111,8 +119,10 @@ def protobuf_deps(): if not native.existing_rule("rules_java"): http_archive( name = "rules_java", - url = "https://github.com/bazelbuild/rules_java/releases/download/8.3.2/rules_java-8.3.2.tar.gz", - sha256 = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/8.6.1/rules_java-8.6.1.tar.gz", + ], + sha256 = "c5bc17e17bb62290b1fd8fdd847a2396d3459f337a7e07da7769b869b488ec26", ) if not native.existing_rule("rules_shell"): @@ -129,9 +139,9 @@ def protobuf_deps(): if not native.existing_rule("rules_python"): http_archive( name = "rules_python", - sha256 = "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8", - strip_prefix = "rules_python-0.28.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.0.tar.gz", + sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07", + strip_prefix = "rules_python-1.0.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz", ) if not native.existing_rule("system_python"): diff --git a/protobuf_extra_deps.bzl b/protobuf_extra_deps.bzl deleted file mode 100644 index a6b49312bf4a..000000000000 --- a/protobuf_extra_deps.bzl +++ /dev/null @@ -1,31 +0,0 @@ -"""Loads the dependencies necessary for the external repositories defined in protobuf_deps.bzl. - -The consumers should use the following WORKSPACE snippet, which loads dependencies -and sets up the repositories protobuf needs: - -``` -http_archive( - name = "com_google_protobuf", - strip_prefix = "protobuf-VERSION", - sha256 = ..., - url = ..., -) - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") - -protobuf_deps() - -load("@com_google_protobuf//:protobuf_extra_deps.bzl", "protobuf_extra_deps") - -protobuf_extra_deps(); -``` -""" - -load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") - -def protobuf_extra_deps(): - """Loads extra dependencies needed for the external repositories defined in protobuf_deps.bzl.""" - - rules_java_dependencies() - - rules_java_toolchains()