Skip to content

Commit

Permalink
Do not match java_binary deploy.jar with wildcard target patterns
Browse files Browse the repository at this point in the history
With the native implementation of `java_binary`, `bazel build //...` would not end up building deploy jars. This is achieved for the Starlark implementation by adding the `manual` tag to the deploy jar rule. Since the list may already be frozen, we need to make a copy.

Closes #17115.

PiperOrigin-RevId: 503071603
Change-Id: I99afdac8c040bf0aecd5a1bf7d4acf529058ac22
  • Loading branch information
fmeum authored and pull[bot] committed Feb 20, 2024
1 parent 31b8171 commit 3789144
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ def register_java_binary_rules(rule_exec, rule_nonexec, rule_nolauncher, rule_cu
deploy_jar_args = _filtered_dict(kwargs, _DEPLOY_JAR_RULE_ATTRS)
if is_test_rule_class:
deploy_jar_args["testonly"] = True

# Do not let the deploy jar be matched by wildcard target patterns.
deploy_jar_args.setdefault("tags", [])
if "manual" not in deploy_jar_args["tags"]:
tags = []
tags.extend(deploy_jar_args["tags"])
tags.append("manual")
deploy_jar_args["tags"] = tags
rule_deploy_jars(
name = kwargs["name"] + DEPLOY_JAR_RULE_NAME_SUFFIX, # to avoid collision
binary = kwargs["name"],
Expand Down

0 comments on commit 3789144

Please sign in to comment.