Add some missing dependencies to the built-in module bazel_tools
This includes `@remote_coverage_tools` (used by `@bazel_tools//tools/test`) and various Java-related repos provided by `@rules_java` (used by `@bazel_tools//tools/jdk`).
Fixes https://github.com/bazelbuild/bazel/issues/15478.
PiperOrigin-RevId: 449458403
diff --git a/src/MODULE.tools b/src/MODULE.tools
index f699b5e..d36bd5f 100644
--- a/src/MODULE.tools
+++ b/src/MODULE.tools
@@ -16,5 +16,18 @@
cc_configure = use_extension("@rules_cc//bzlmod:extensions.bzl", "cc_configure")
use_repo(cc_configure, "local_config_cc", "local_config_xcode")
+java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
+use_repo(
+ java_toolchains,
+ "local_jdk",
+ "remote_java_tools",
+ "remote_java_tools_linux",
+ "remote_java_tools_windows",
+ "remote_java_tools_darwin",
+)
+
sh_configure_extension = use_extension("//tools/sh:sh_configure.bzl", "sh_configure_extension")
use_repo(sh_configure_extension, "local_config_sh")
+
+remote_coverage_tools_extension = use_extension("//tools/test:extensions.bzl", "remote_coverage_tools_extension")
+use_repo(remote_coverage_tools_extension, "remote_coverage_tools")
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD
index 5a94a07..f8eedfc 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD
@@ -126,7 +126,7 @@
# 1. bazel build tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:coverage_output_generator_zip
# 2. Copy and rename the zip file with a new version locally.
# 3. Upload the file under https://mirror.bazel.build/bazel_coverage_output_generator/releases.
-# 4. Update //distdir_deps.bzl to point to the new release.
+# 4. Update //distdir_deps.bzl and //tools/test/extensions.bzl to point to the new release.
gen_workspace_stanza(
name = "workspace_with_coverage_output_generator",
out = "coverage.WORKSPACE",
diff --git a/tools/BUILD b/tools/BUILD
index 1d257df..cddfc5b 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -84,6 +84,7 @@
"//tools/osx:bzl_srcs",
"//tools/python:bzl_srcs",
"//tools/sh:bzl_srcs",
+ "//tools/test:bzl_srcs",
"//tools/windows:bzl_srcs",
],
)
diff --git a/tools/test/BUILD b/tools/test/BUILD
index 2d67ce3..2d9b35b 100644
--- a/tools/test/BUILD
+++ b/tools/test/BUILD
@@ -115,6 +115,7 @@
"generate-xml.sh",
"collect_coverage.sh",
"collect_cc_coverage.sh",
+ "extensions.bzl",
] + select({
"@bazel_tools//src/conditions:windows": [
"tw",
@@ -126,3 +127,8 @@
}),
visibility = ["//tools:__pkg__"],
)
+
+filegroup(
+ name = "bzl_srcs",
+ srcs = ["extensions.bzl"],
+)
diff --git a/tools/test/BUILD.tools b/tools/test/BUILD.tools
index 39658c8..fa7bb23 100644
--- a/tools/test/BUILD.tools
+++ b/tools/test/BUILD.tools
@@ -65,3 +65,8 @@
"//conditions:default": ["dummy.sh"],
}),
)
+
+filegroup(
+ name = "bzl_srcs",
+ srcs = ["extensions.bzl"],
+)
diff --git a/tools/test/extensions.bzl b/tools/test/extensions.bzl
new file mode 100644
index 0000000..30afe4d
--- /dev/null
+++ b/tools/test/extensions.bzl
@@ -0,0 +1,30 @@
+# Copyright 2022 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""A module extension to bring in the remote coverage tools under
+@remote_coverage_tools."""
+
+load("//tools/build_defs/repo:http.bzl", "http_archive")
+
+def _remote_coverage_tools_extension_impl(ctx):
+ http_archive(
+ name = "remote_coverage_tools",
+ sha256 = "7006375f6756819b7013ca875eab70a541cf7d89142d9c511ed78ea4fefa38af",
+ urls = [
+ "https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.6.zip",
+ ],
+ )
+
+remote_coverage_tools_extension = module_extension(
+ implementation = _remote_coverage_tools_extension_impl,
+)