diff --git a/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_deploy_jar.bzl b/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_deploy_jar.bzl index 204de369a57a93..7e426797e3b3a7 100644 --- a/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_deploy_jar.bzl +++ b/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_deploy_jar.bzl @@ -59,4 +59,7 @@ def _bazel_deploy_jars_impl(ctx): return [] -deploy_jars = make_deploy_jars_rule(implementation = _bazel_deploy_jars_impl) +deploy_jars = make_deploy_jars_rule( + implementation = _bazel_deploy_jars_impl, + needs_runtime = False, +) diff --git a/src/main/starlark/builtins_bzl/common/java/java_binary_deploy_jar.bzl b/src/main/starlark/builtins_bzl/common/java/java_binary_deploy_jar.bzl index b86aa36b41a446..e672270a9984d2 100644 --- a/src/main/starlark/builtins_bzl/common/java/java_binary_deploy_jar.bzl +++ b/src/main/starlark/builtins_bzl/common/java/java_binary_deploy_jar.bzl @@ -254,7 +254,7 @@ def _implicit_outputs(binary): "unstrippeddeployjar": "%s_deploy.jar.unstripped" % binary_name, } -def make_deploy_jars_rule(implementation): +def make_deploy_jars_rule(implementation, needs_runtime = True): """Creates the deploy jar auxiliary rule for java_binary Args: @@ -274,12 +274,19 @@ def make_deploy_jars_rule(implementation): ), "_cc_toolchain": attr.label(default = "@" + cc_semantics.get_repo() + "//tools/cpp:current_cc_toolchain"), "_java_toolchain_type": attr.label(default = semantics.JAVA_TOOLCHAIN_TYPE), - "_java_runtime_toolchain_type": attr.label(default = semantics.JAVA_RUNTIME_TOOLCHAIN_TYPE), "_build_info_translator": attr.label( default = semantics.BUILD_INFO_TRANSLATOR_LABEL, ), - }, + } | ( + { + "_java_runtime_toolchain_type": attr.label( + default = semantics.JAVA_RUNTIME_TOOLCHAIN_TYPE, + ), + } if needs_runtime else {} + ), outputs = _implicit_outputs, fragments = ["java"], - toolchains = [semantics.JAVA_TOOLCHAIN, semantics.JAVA_RUNTIME_TOOLCHAIN] + cc_helper.use_cpp_toolchain(), + toolchains = [semantics.JAVA_TOOLCHAIN] + cc_helper.use_cpp_toolchain() + ( + [semantics.JAVA_RUNTIME_TOOLCHAIN] if needs_runtime else [] + ), )