Skip to content
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

Include classifier in label if present #467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gmishkin
Copy link

My use case is, I have a bzl file with a function that returns a list of all our artifacts. The function is called for both the artifacts attr of maven_install in the WORKSPACE and in another rule where I pass [artifact(a) for a in get_rje_artifacts()] as inputs to a custom rule we have. I also use strict_visibility

What happened was that for the artifact that has a classifier, the label returned wasn't valid and so my custom rule failed to build.

I was able to fix it like this.

@jin jin self-assigned this Oct 21, 2020
Copy link
Member

@jin jin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the target labels are generated without the classifier. I'm not sure if this is the right change.

target_label = escape(strip_packaging_and_classifier_and_version(artifact["coord"]))

def strip_packaging_and_classifier_and_version(coord):

@jin
Copy link
Member

jin commented Nov 13, 2020

Do you have a repro example?

@gmishkin
Copy link
Author

@jin I'll try to construct a minimal repro, but I think the gist was:

  • I have a function that returns the list to pass to maven_install, which includes
def get_rje_artifacts():
  return [
    maven.artifact("com.google.googlejavaformat", "google-java-format", "1.8", classifier = "all-deps")`,
    # ...
  ]
  • I have a rule takes in jars that I pass artifact() (from defs.bzl) on the above to
jar_index(
    name = "external_jar_index",
    jars = [artifact(a) for a in get_rje_artifacts()]
)

Without this patch, the label it ends up passing to the jars attr is not valid because it doesn't have the classifier in the labe.

@SanyaLuc
Copy link

SanyaLuc commented Dec 21, 2023

@gmishkin It is sad that nobody from repo owners followed up with you, but I found that classifier attribute already exists, just slightly not intuitive format https://groups.google.com/g/bazel-discuss/c/ssIF7MBbN-k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants