Skip to content

Commit

Permalink
Remove unused Java runtime dependency of Bazel deploy jar rule
Browse files Browse the repository at this point in the history
Bazel's deploy jar rule never uses the hermetic runtime feature and thus
doesn't need a Java runtime dependency.
  • Loading branch information
fmeum committed Aug 1, 2023
1 parent 404eb64 commit bc09e22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 []
),
)

0 comments on commit bc09e22

Please sign in to comment.