Add redirects to Java providers and modules that can be loaded PiperOrigin-RevId: 474769759 Change-Id: I2b87fffefad390e7abb0ab57a848ad752e230b91
diff --git a/WORKSPACE b/WORKSPACE index e4bdea6..4a8ef2b 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -4,10 +4,10 @@ http_archive( name = "bazel_federation", - sha256 = "33222ab7bcc430f1ff1db8788c2e0118b749319dd572476c4fd02322d7d15792", - strip_prefix = "bazel-federation-f0e5eda7f0cbfe67f126ef4dacb18c89039b0506", + sha256 = "0d6893f0d18f417a3324ce7f0ed2e6e5b825d6d5ab42f0f3d7877cb313f36453", + strip_prefix = "bazel-federation-6ad33bc586701e9836a2bf4432c7aff1235b04d2", type = "zip", - url = "https://github.com/bazelbuild/bazel-federation/archive/f0e5eda7f0cbfe67f126ef4dacb18c89039b0506.zip", # 2019-09-30 + url = "https://github.com/bazelbuild/bazel-federation/archive/6ad33bc586701e9836a2bf4432c7aff1235b04d2.zip", # 2021-07-12 ) load("@bazel_federation//:repositories.bzl", "rules_java_deps")
diff --git a/internal_deps.bzl b/internal_deps.bzl index 463c1f8..1629dac 100644 --- a/internal_deps.bzl +++ b/internal_deps.bzl
@@ -14,8 +14,9 @@ """Dependencies that are needed for rules_java tests and tools.""" -load("@bazel_federation//:repositories.bzl", "rules_pkg") +load("@bazel_federation//:repositories.bzl", "bazel_skylib", "rules_pkg") def rules_java_internal_deps(): """Fetches all required dependencies for rules_java tests and tools.""" + bazel_skylib() rules_pkg()
diff --git a/java/BUILD b/java/BUILD index 510dfbe..dcd13e0 100644 --- a/java/BUILD +++ b/java/BUILD
@@ -14,4 +14,5 @@ name = "rules", srcs = ["defs.bzl"], visibility = ["//visibility:public"], + deps = ["//java/private"], )
diff --git a/java/defs.bzl b/java/defs.bzl index 51947bd..1e1ada1 100644 --- a/java/defs.bzl +++ b/java/defs.bzl
@@ -13,6 +13,8 @@ # limitations under the License. """Starlark rules for building Java projects.""" +load("//java/private:native.bzl", "NativeJavaInfo", "NativeJavaPluginInfo", "native_java_common") + # Do not touch: This line marks the end of loads; needed for PR importing. _MIGRATION_TAG = "__JAVA_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" @@ -144,3 +146,9 @@ # buildifier: disable=native-java native.java_toolchain(**_add_tags(attrs)) + +java_common = native_java_common + +JavaInfo = NativeJavaInfo + +JavaPluginInfo = NativeJavaPluginInfo
diff --git a/java/private/BUILD b/java/private/BUILD new file mode 100644 index 0000000..5f8ce72 --- /dev/null +++ b/java/private/BUILD
@@ -0,0 +1,9 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +licenses(["notice"]) + +bzl_library( + name = "private", + srcs = ["native.bzl"], + visibility = ["//visibility:public"], +)
diff --git a/java/private/native.bzl b/java/private/native.bzl new file mode 100644 index 0000000..64a4d5a --- /dev/null +++ b/java/private/native.bzl
@@ -0,0 +1,31 @@ +# 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. + +# Redefine native symbols with a new name as a workaround for +# exporting them in `//third_party/bazel_rules/rules_proto/proto:defs.bzl` with their original name. +# +# While we cannot force users to load these symbol due to the lack of a +# allowlisting mechanism, we can still export them and tell users to +# load it to make a future migration to pure Starlark easier. + +"""Lovely workaround to be able to expose native constants pretending to be Starlark.""" + +# buildifier: disable=native-java +native_java_common = java_common + +# buildifier: disable=native-java +NativeJavaInfo = JavaInfo + +# buildifier: disable=native-java +NativeJavaPluginInfo = JavaPluginInfo