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

Add classifier_artifacts parameter to java_export to allow users to publish extra artifacts #926

Merged
merged 9 commits into from
Aug 17, 2023

Conversation

thirtyseven
Copy link
Contributor

@thirtyseven thirtyseven commented Jun 29, 2023

This PR addresses the remaining issues in #805 which got pretty close to being mergeable. I also renamed "extra_artifacts" to "classifier_artifacts" to stick closer to Maven terminology. Also, since javadocs and source jars are special cases of classifier artifacts, I refactored them to use the same code path.

@thirtyseven thirtyseven requested a review from cheister as a code owner June 29, 2023 09:28
@thirtyseven thirtyseven changed the title Add classifier_artifacts parameter to java_export to allow users to add extra artifacts Add classifier_artifacts parameter to java_export to allow users to publish extra artifacts Jun 29, 2023
Copy link
Collaborator

@shs96c shs96c left a comment

Choose a reason for hiding this comment

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

Looks good, but a couple of minor things.

@@ -235,13 +239,16 @@ def maven_export(
testonly = testonly,
)

classifier_artifacts = dict(classifier_artifacts) # unfreeze
classifier_artifacts.setdefault("sources", ":%s-maven-source" % name)
classifier_artifacts.setdefault("javadoc", docs_jar)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Neither sources not javadoc are mandatory in some cases (eg. when publishing a BOM), so please check that these values are set before adding them to the dict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The javadoc case was already addressed implicitly on line 251 with if v in the dict comprehension, but I've made it more explicit in the latest commit. Not sure how to address the sources case, it's created unconditionally in the current implementation of the java_export, maven_bom is a separate macro not addressed by this PR.


classifier_artifacts_dict = {}
for target, classifier in ctx.attr.classifier_artifacts.items():
file = target.files.to_list()[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm... this makes me nervous. Could we check that there's only one file and print a warning if there's more than one? I've a vague memory that (maybe) the kotlin rules have more than one output sometimes....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some checks here.

@thirtyseven thirtyseven requested a review from shs96c July 10, 2023 13:40
Copy link
Collaborator

@shs96c shs96c left a comment

Choose a reason for hiding this comment

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

Alright! Let's see what happens when this lands :) LGTM

@shs96c
Copy link
Collaborator

shs96c commented Aug 17, 2023

@thirtyseven, I hate to ask for more after the delay in getting this review finished, but could you please rebase?

@thirtyseven
Copy link
Contributor Author

@thirtyseven, I hate to ask for more after the delay in getting this review finished, but could you please rebase?

Done

@shs96c shs96c merged commit 5e9a6d3 into bazel-contrib:master Aug 17, 2023
@shs96c
Copy link
Collaborator

shs96c commented Aug 17, 2023

Fantastic. Thank you! Merged! :)

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

Successfully merging this pull request may close these issues.

2 participants