Skip to content

Fix Bazel 8.2.1 WORKSPACE builds, bump dev deps #1748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Remove once Bazel 8 becomes the minimum supported version.
common --noenable_workspace --incompatible_use_plus_in_repo_names
common --noenable_workspace --incompatible_use_plus_in_repo_names --incompatible_autoload_externally=

# Uncomment to run tests under `WORKSPACE`. Remove once Bazel 9 becomes the
# minimum supported version.
#common --enable_workspace --noenable_bzlmod

# Uncomment for WORKSPACE builds for Bazel [8.0.0, 8.3.0) per:
# https://github.com/bazelbuild/rules_java/releases/tag/8.12.0
Expand Down
4 changes: 4 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For //tools:lint_check, which requires a `workspace` attribute. However, this
# can be any file, and `WORKSPACE` is going away one day. See:
# https://github.com/bazelbuild/buildtools/blob/v8.2.1/buildifier/runner.bash.template
exports_files(["MODULE.bazel"])
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,4 @@ use_repo(
)

bazel_dep(name = "rules_python", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.4.1", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.5.0", dev_dependency = True)
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ register_toolchains("//test/toolchains:java21_toolchain_definition")

http_archive(
name = "rules_shell",
sha256 = "bc61ef94facc78e20a645726f64756e5e285a045037c7a61f65af2941f4c25e1",
strip_prefix = "rules_shell-0.4.1",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.1/rules_shell-v0.4.1.tar.gz",
sha256 = "b15cc2e698a3c553d773ff4af35eb4b3ce2983c319163707dddd9e70faaa062d",
strip_prefix = "rules_shell-0.5.0",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.5.0/rules_shell-v0.5.0.tar.gz",
)

load(
Expand Down
18 changes: 18 additions & 0 deletions scala/latest_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,21 @@ def rules_scala_dependencies():
strip_prefix = "rules_proto-7.1.0",
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz",
)

# Resolves the following error when building under `WORKSPACE` with Bazel 8.2.1,
# `protobuf` v31.1, and `rules_java` 8.12.0:
# https://github.com/protocolbuffers/protobuf/pull/19129#issuecomment-2968934424
rules_jvm_external_tag = "6.7"
rules_jvm_external_sha = (
"a1e351607f04fed296ba33c4977d3fe2a615ed50df7896676b67aac993c53c18"
)
maybe(
http_archive,
name = "rules_jvm_external",
sha256 = rules_jvm_external_sha,
strip_prefix = "rules_jvm_external-%s" % rules_jvm_external_tag,
url = "https://github.com/bazel-contrib/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (
rules_jvm_external_tag,
rules_jvm_external_tag,
),
)
11 changes: 8 additions & 3 deletions scala/private/extensions/dev_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ load(
)
load("//third_party/repositories:repositories.bzl", "repositories")

_BUILD_TOOLS_RELEASE = "5.1.0"
_BUILD_TOOLS_RELEASE = "8.2.1"
_BUILD_TOOLS_INTEGRITY = "sha256-UxGTl7vOHNfkxZDhF9zaNDwghhmd5ikyEGyAczUmwmE="

_settings_defaults = {
"maven_servers": default_maven_server_urls(),
Expand Down Expand Up @@ -41,12 +42,16 @@ def dev_deps_repositories(
maven_servers: servers to use when resolving Maven artifacts
fetch_sources: retrieve Maven artifact sources when True
"""

# gazelle is still getting `buildtools` from its `go.mod` file, which breaks
# `bazel run //tools:lint_check` when we don't import it like this. See:
# - https://github.com/bazel-contrib/bazel-gazelle/blob/v0.43.0/MODULE.bazel#L32-L44
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "e3bb0dc8b0274ea1aca75f1f8c0c835adbe589708ea89bf698069d0790701ea3",
integrity = _BUILD_TOOLS_INTEGRITY,
strip_prefix = "buildtools-%s" % _BUILD_TOOLS_RELEASE,
url = (
"https://github.com/bazelbuild/buildtools/archive/%s.tar.gz" %
"https://github.com/bazelbuild/buildtools/archive/v%s.tar.gz" %
_BUILD_TOOLS_RELEASE
),
)
Expand Down
7 changes: 6 additions & 1 deletion scala/scala_maven_import_external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_netrc", "read_user_n
_SCALA_IMPORT_RULE_LOAD = (
"load(\"%s\", \"scala_import\")" % Label("//scala:scala_import.bzl")
)
_JAVA_IMPORT_RULE_LOAD = (
"load(\"@rules_java//java:java_import.bzl\", \"java_import\")"
)

# https://github.com/bazelbuild/bazel/issues/13709#issuecomment-1336699672
def _get_auth(ctx, urls):
Expand Down Expand Up @@ -97,6 +100,7 @@ def _jvm_import_external_impl(repository_ctx):
lines.append("package(default_visibility = %s)" %
(repository_ctx.attr.default_visibility))
lines.append("")

lines.append("licenses(%s)" % repr(repository_ctx.attr.licenses))
lines.append("")
lines.extend(
Expand Down Expand Up @@ -229,6 +233,7 @@ def _serialize_given_rule_import(
lines.append("")
return lines

# buildifier: disable=attr-licenses
_jvm_import_external = repository_rule(
implementation = _jvm_import_external_impl,
attrs = {
Expand All @@ -237,7 +242,7 @@ _jvm_import_external = repository_rule(
"jar_urls": attr.string_list(mandatory = True, allow_empty = False),
"jar_sha256": attr.string(doc = "'jar_sha256' is deprecated. Please use 'artifact_sha256'"),
"artifact_sha256": attr.string(),
"rule_load": attr.string(),
"rule_load": attr.string(default = _JAVA_IMPORT_RULE_LOAD),
"additional_rule_attrs": attr.string_dict(),
"srcjar_urls": attr.string_list(),
"srcjar_sha256": attr.string(),
Expand Down
10 changes: 8 additions & 2 deletions tools/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load(
"@com_github_bazelbuild_buildtools//buildifier:def.bzl",
"buildifier",
"buildifier_test",
)

WARNINGS_CONFIG = [
"-module-docstring",
Expand All @@ -16,14 +20,16 @@ WARNINGS_CONFIG = [
"-unused-variable",
]

buildifier(
buildifier_test(
name = "lint_check",
exclude_patterns = [
"./.ijwb/*",
],
lint_mode = "warn",
lint_warnings = WARNINGS_CONFIG,
mode = "check",
no_sandbox = True,
workspace = "//:MODULE.bazel",
)

buildifier(
Expand Down