square / bazel_maven_repository

A bazel ruleset creating a more idiomatic bazel representation of a maven repo using a pinned list of artifacts.
Apache License 2.0
39 stars 11 forks source link

Support an alias configuration for artifacts #60

Open cgruber opened 5 years ago

cgruber commented 5 years ago

Presently artifacts are named for their artifactId (possibly munged). However, this is sometimes inconvenient, as in the case of something like hamcrest-core or assertj-core. There should be a way to specify an alias target with a different name, which will pass-through to the default target.

The alias should be publicly visible, and the mvn_jvm_import should be reduced in visibility to //visibility:@maven//__subpackages__ (generated with the appropriate workspace name in place of maven). This allows existing inter-dependencies logic to work unmodified, but the public alias will be the means by which deps not in the maven workspace reference this artifact.

e.g.:

maven_repository_specification(
    name = "maven",
    artifacts = {
        "org.mockito:mockito-core:2.7.5": { "sha256": "blah", "alias" = "mockito" }
    },
)

This would generate

alias(name = "mockito", actual = ":mockito_core")

maven_jvm_artifact(
    name = "mockito_core",
    artifact = "org.mockito:mockito-core:2.7.5",
    visibility = "//visibility:@maven//__subpackages__",
    deps = [
        "@maven//net/bytebuddy:byte_buddy",
        "@maven//net/bytebuddy:byte_buddy_agent",
        "@maven//org/objenesis",
    ]
)

Implements part of #52

cgruber commented 5 years ago

Implements part of #52