Skip to content

Commit 17ef600

Browse files
committed
Use rctx.name if rctx.original_name is empty
Works around breakages when building under `WORKSPACE` with Bazel 8.1.0, as described in bazelbuild/bazel#25286. Part of bazel-contrib#1652. PR bazel-contrib#1694 added support for `rctx.original_name` after the implementation of bazelbuild/bazel#24467 landed in 8.1.0rc2. However, I hadn't tested `WORKSPACE` builds with 8.1.0rc2 before 8.1.0 came out. This resolves the breakage until a Bazel 8 release containing a fix for bazelbuild/bazel#25286 becomes available (possibly Bazel 8.2.0).
1 parent 9041747 commit 17ef600

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

scala/scala_maven_import_external.bzl

+6-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ def _jvm_import_external_impl(repository_ctx):
6969
not repository_ctx.attr.neverlink):
7070
fail("Only use generated_linkable_rule_name if neverlink is set")
7171

72-
# Replace with rctx.original_name once all supported Bazels have it
73-
repo_name = getattr(repository_ctx, "original_name", repository_ctx.name)
72+
# Replace with rctx.original_name once all supported Bazels have it.
73+
# Remove `or rctx.name` after Bazel fixes bazelbuild/bazel#25286.
74+
repo_name = (
75+
getattr(repository_ctx, "original_name", repository_ctx.name) or
76+
repository_ctx.name
77+
)
7478
name = repository_ctx.attr.generated_rule_name or repo_name
7579
urls = repository_ctx.attr.jar_urls
7680
if repository_ctx.attr.jar_sha256:

third_party/repositories/repositories.bzl

+6-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,12 @@ def repositories(
141141
def _alias_repository_impl(rctx):
142142
""" Builds a repository containing just two aliases to the Scala Maven artifacts in the `target` repository. """
143143
format_kwargs = {
144-
# Replace with rctx.original_name once all supported Bazels have it
145-
"name": getattr(rctx, "original_name", rctx.attr.default_target_name),
144+
# Replace with rctx.original_name once all supported Bazels have it.
145+
# Remove `or rctx.name` after Bazel fixes bazelbuild/bazel#25286.
146+
"name": (
147+
getattr(rctx, "original_name", rctx.attr.default_target_name) or
148+
rctx.name
149+
),
146150
"target": rctx.attr.target,
147151
}
148152
rctx.file("BUILD", """alias(

0 commit comments

Comments
 (0)