Skip to content

Commit

Permalink
Fix proto_support.bzl for Bazel
Browse files Browse the repository at this point in the history
Work towards bazelbuild/bazel#24543

PiperOrigin-RevId: 702587292
Change-Id: I5feb477d86c059008ed78b58588a7a6fe7976e20
  • Loading branch information
hvadehra authored and rules_java Copybara committed Dec 4, 2024
1 parent 36a3669 commit 934c1b2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
4 changes: 1 addition & 3 deletions java/common/rules/basic_java_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ load("//java/private:java_common.bzl", "java_common")
load("//java/private:java_info.bzl", "JavaPluginInfo")
load(":rule_util.bzl", "merge_attrs")

visibility([
"//java/...",
])
# copybara: default multiline visibility

BASIC_JAVA_LIBRARY_IMPLICIT_ATTRS = merge_attrs(
{
Expand Down
4 changes: 1 addition & 3 deletions java/common/rules/impl/basic_java_library_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ load("//java/private:java_info.bzl", "JavaInfo", "JavaPluginInfo")
load(":compile_action.bzl", "compile_action")
load(":proguard_validation.bzl", "validate_proguard_specs")

visibility([
"//java/...",
])
# copybara: default multiline visibility

def _filter_srcs(srcs, ext):
return [f for f in srcs if f.extension == ext]
Expand Down
4 changes: 1 addition & 3 deletions java/private/java_common_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ load(
)
load(":native.bzl", "get_internal_java_common")

visibility([
"//java/...",
])
# copybara: default multiline visibility

def compile(
ctx,
Expand Down
28 changes: 20 additions & 8 deletions java/private/proto_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@
# limitations under the License.
"""Support for Java compilation of protocol buffer generated code."""

load("@compatibility_proxy//:proxy.bzl", "java_common")
load("@compatibility_proxy//:proxy.bzl", "java_common", "java_common_internal_compile", "java_info_internal_merge")

# Partial support, because internal symbols are not available in older Bazel version
# TODO: Once Java rules are moved into the rules_java, this should become a full support.
def compile(*, injecting_rule_kind, enable_jspecify, include_compilation_info, **kwargs):
if java_common_internal_compile:
return java_common_internal_compile(
injecting_rule_kind = injecting_rule_kind,
enable_jspecify = enable_jspecify,
include_compilation_info = include_compilation_info,
**kwargs
)
else:
return java_common.compile(**kwargs)

def compile(*, injecting_rule_kind, enable_jspecify, include_compilation_info, **kwargs): # buildifier: disable=unused-variable
return java_common.compile(**kwargs)

def merge(providers, *, merge_java_outputs = True, merge_source_jars = True): # buildifier: disable=unused-variable
return java_common.merge(providers)
def merge(providers, *, merge_java_outputs = True, merge_source_jars = True):
if java_info_internal_merge:
return java_info_internal_merge(
providers,
merge_java_outputs = merge_java_outputs,
merge_source_jars = merge_source_jars,
)
else:
return java_common.merge(providers)
8 changes: 6 additions & 2 deletions java/rules_java_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ load("@rules_java//java/common/rules:java_package_configuration.bzl", _java_pack
load("@rules_java//java/common/rules:java_runtime.bzl", _java_runtime = "java_runtime")
load("@rules_java//java/common/rules:java_toolchain.bzl", _java_toolchain = "java_toolchain")
load("@rules_java//java/private:java_common.bzl", _java_common = "java_common")
load("@rules_java//java/private:java_info.bzl", _JavaInfo = "JavaInfo", _JavaPluginInfo = "JavaPluginInfo")
load("@rules_java//java/private:java_common_internal.bzl", _java_common_internal_compile = "compile")
load("@rules_java//java/private:java_info.bzl", _JavaInfo = "JavaInfo", _JavaPluginInfo = "JavaPluginInfo", _java_info_internal_merge = "merge")
load("@rules_java//java:http_jar.bzl", _http_jar = "http_jar")
java_binary = _java_binary
Expand All @@ -51,7 +52,8 @@ java_toolchain = _java_toolchain
java_common = _java_common
JavaInfo = _JavaInfo
JavaPluginInfo = _JavaPluginInfo
java_common_internal_compile = _java_common_internal_compile
java_info_internal_merge = _java_info_internal_merge
http_jar = _http_jar
""",
)
Expand Down Expand Up @@ -91,6 +93,8 @@ java_toolchain = native.java_toolchain
java_common = native_java_common
JavaInfo = NativeJavaInfo
JavaPluginInfo = NativeJavaPluginInfo
java_common_internal_compile = None
java_info_internal_merge = None
http_jar = _http_jar
""",
Expand Down

0 comments on commit 934c1b2

Please sign in to comment.