From af4b48c3a23ef92eb4139fdcd495a9dad4ecfd9f Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 14 Feb 2023 05:17:04 -0800 Subject: [PATCH] Do not instanatiate deploy jars for java_test PiperOrigin-RevId: 509496793 Change-Id: Ia902648c803880da876fe90d85585853465466ff --- .../builtins_bzl/bazel/java/bazel_java_binary_wrapper.bzl | 2 +- .../builtins_bzl/common/java/java_binary_wrapper.bzl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_wrapper.bzl b/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_wrapper.bzl index 2857c57af5c6c2..5965a9c83f46db 100644 --- a/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_wrapper.bzl +++ b/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary_wrapper.bzl @@ -31,6 +31,6 @@ def java_binary(**kwargs): java_bin_nonexec, java_bin_exec_no_launcher_flag, java_bin_exec, - deploy_jars, + rule_deploy_jars = deploy_jars, **kwargs ) diff --git a/src/main/starlark/builtins_bzl/common/java/java_binary_wrapper.bzl b/src/main/starlark/builtins_bzl/common/java/java_binary_wrapper.bzl index 66260d755ca66b..f9a5a10ecf63ef 100644 --- a/src/main/starlark/builtins_bzl/common/java/java_binary_wrapper.bzl +++ b/src/main/starlark/builtins_bzl/common/java/java_binary_wrapper.bzl @@ -20,7 +20,7 @@ the supplied value of the `create_executable` attribute. load(":common/java/java_binary_deploy_jar.bzl", "DEPLOY_JAR_RULE_NAME_SUFFIX") -def register_java_binary_rules(rule_exec, rule_nonexec, rule_nolauncher, rule_customlauncher, rule_deploy_jars, is_test_rule_class = False, **kwargs): +def register_java_binary_rules(rule_exec, rule_nonexec, rule_nolauncher, rule_customlauncher, rule_deploy_jars = None, is_test_rule_class = False, **kwargs): """Registers the correct java_binary rule and deploy jar rule Args: @@ -45,7 +45,9 @@ def register_java_binary_rules(rule_exec, rule_nonexec, rule_nolauncher, rule_cu else: rule_exec(**kwargs) - if not kwargs.get("tags", []) or "nodeployjar" not in kwargs.get("tags", []): + if rule_deploy_jars and ( + not kwargs.get("tags", []) or "nodeployjar" not in kwargs.get("tags", []) + ): deploy_jar_args = _filtered_dict(kwargs, _DEPLOY_JAR_RULE_ATTRS) if is_test_rule_class: deploy_jar_args["testonly"] = True