Skip to content

Commit

Permalink
Merge pull request #107 from cgruber/visible_alii
Browse files Browse the repository at this point in the history
Fix visibility of legacy aliases.
  • Loading branch information
cgruber authored May 14, 2020
2 parents aa56fdf + b4862ca commit b804584
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions maven/maven.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ _ANDROID_LOAD_PREFIX = """load("@build_bazel_rules_android//android:rules.bzl",

_LEGACY_LOAD_PREFIX = """load("@{repo}//maven:maven.bzl", "maven_jvm_artifact")"""

_LEGACY_ALIAS_TEMPLATE = """alias(name = "{alias}", actual = "{actual}")"""
_LEGACY_ALIAS_TEMPLATE = """alias(
name = "{alias}",
actual = "{actual}",
visibility = {visibility},
)"""

_MAVEN_REPO_JVM_TARGET_TEMPLATE = """
# {spec}
Expand Down Expand Up @@ -343,9 +347,13 @@ def _generate_maven_repository_impl(ctx):
testonly_artifacts,
artifact.coordinate,
) else ""
underscore_alias = _underscore_alias(ctx.attr.legacy_underscore, artifact)
visibility = """["//visibility:public"]"""
underscore_alias = _underscore_alias(
ctx.attr.legacy_underscore,
artifact,
visibility,
)
fetch_repo = "@%s//%s" % (artifact.maven_target_name, _DOWNLOAD_PREFIX)
visibility = ["//visibility:public"]
if artifact.packaging == "aar":
add_android_prefix = True
manifest = manifests[artifact.maven_target_name]
Expand Down Expand Up @@ -386,7 +394,7 @@ def _generate_maven_repository_impl(ctx):
)
ctx.file(file, content)

def _underscore_alias(enabled, artifact):
def _underscore_alias(enabled, artifact, visibility):
if not enabled:
return ""
alias = artifact.third_party_target_name.replace("-", "_")
Expand All @@ -395,6 +403,7 @@ def _underscore_alias(enabled, artifact):
return _LEGACY_ALIAS_TEMPLATE.format(
alias = alias,
actual = ":%s" % artifact.third_party_target_name,
visibility = visibility,
)

_generate_maven_repository = repository_rule(
Expand Down

0 comments on commit b804584

Please sign in to comment.