Skip to content

Use rctx.name if rctx.original_name is empty #1702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scala/scala_maven_import_external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ def _jvm_import_external_impl(repository_ctx):
not repository_ctx.attr.neverlink):
fail("Only use generated_linkable_rule_name if neverlink is set")

# Replace with rctx.original_name once all supported Bazels have it
repo_name = getattr(repository_ctx, "original_name", repository_ctx.name)
# Replace with rctx.original_name once all supported Bazels have it.
# Remove `or rctx.name` after Bazel fixes bazelbuild/bazel#25286.
repo_name = (
getattr(repository_ctx, "original_name", repository_ctx.name) or
repository_ctx.name
)
name = repository_ctx.attr.generated_rule_name or repo_name
urls = repository_ctx.attr.jar_urls
if repository_ctx.attr.jar_sha256:
Expand Down
8 changes: 6 additions & 2 deletions third_party/repositories/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ def repositories(
def _alias_repository_impl(rctx):
""" Builds a repository containing just two aliases to the Scala Maven artifacts in the `target` repository. """
format_kwargs = {
# Replace with rctx.original_name once all supported Bazels have it
"name": getattr(rctx, "original_name", rctx.attr.default_target_name),
# Replace with rctx.original_name once all supported Bazels have it.
# Remove `or rctx.name` after Bazel fixes bazelbuild/bazel#25286.
"name": (
getattr(rctx, "original_name", rctx.attr.default_target_name) or
rctx.name
),
"target": rctx.attr.target,
}
rctx.file("BUILD", """alias(
Expand Down