-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Expose list of all artifacts, including transitive #648
Merged
shs96c
merged 4 commits into
bazel-contrib:master
from
dmivankov:expose_all_artifacts_list
Jan 27, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
43a482b
Expose list of all artifacts, including transitive
dmivankov f3eb06a
handle full coord dict case in artifact() macro
dmivankov bcdef21
Add versionless test case for strip_packaging_and_classifier_and_version
dmivankov 8b82fe1
Document artifact macro and dependencies list in README
dmivankov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
load("//:specs.bzl", "parse") | ||
load("//private:constants.bzl", "DEFAULT_REPOSITORY_NAME") | ||
load("//private:coursier_utilities.bzl", "strip_packaging_and_classifier_and_version") | ||
|
||
def artifact(a, repository_name = DEFAULT_REPOSITORY_NAME): | ||
artifact_obj = _parse_artifact_str(a) if type(a) == "string" else a | ||
return "@%s//:%s" % (repository_name, _escape(artifact_obj["group"] + ":" + artifact_obj["artifact"])) | ||
artifact_str = _make_artifact_str(a) if type(a) != "string" else a | ||
return "@%s//:%s" % (repository_name, _escape(strip_packaging_and_classifier_and_version(artifact_str))) | ||
|
||
def maven_artifact(a): | ||
return artifact(a, repository_name = DEFAULT_REPOSITORY_NAME) | ||
|
||
def _escape(string): | ||
return string.replace(".", "_").replace("-", "_").replace(":", "_") | ||
|
||
def _parse_artifact_str(artifact_str): | ||
pieces = artifact_str.split(":") | ||
if len(pieces) == 2: | ||
return {"group": pieces[0], "artifact": pieces[1]} | ||
else: | ||
return parse.parse_maven_coordinate(artifact_str) | ||
# inverse of parse_maven_coordinate | ||
def _make_artifact_str(artifact_obj): | ||
# produce either simplified g:a or standard g:a:[p:[c:]]v Maven coordinate string | ||
coord = [artifact_obj["group"], artifact_obj["artifact"]] | ||
if "version" in artifact_obj: | ||
if "packaging" in artifact_obj: | ||
coord.extend([artifact_obj["packaging"]]) | ||
if "classifier" in artifact_obj: | ||
coord.extend([artifact_obj["classifier"]]) | ||
coord.extend([artifact_obj["version"]]) | ||
return ":".join(coord) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding a test to
tests/unit/coursier_utilities_test.bzl
for this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a test case now