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

fix(bazel): generate java assembly for type-only #169

Merged
merged 3 commits into from
Aug 4, 2023

Conversation

noahdietz
Copy link
Contributor

For type-only packages (those that don't have any proto service definitions), stop generate java_grpc_library (no code would be generated anyways) and add java_gapic_assembly_gradle_pkg in order to enable publication of the Java classes.

Note: This is implementation is different from the inspiration CL in a few ways:

  • uses a different, type-only package name (these target names don't really matter when bazel-bot only looks for tarball outputs)
  • includes the proto_library target in the generated output (the inspiration CL did not)

cc: @blakeli0

Part of b/281092541.

@noahdietz noahdietz requested a review from a team as a code owner August 4, 2023 19:22
@noahdietz noahdietz requested a review from blakeli0 August 4, 2023 19:38
@noahdietz noahdietz dismissed alexander-fenster’s stale review August 4, 2023 19:38

didn't have Blake in owners before, now we do

deps = [":{{name}}_java_proto"],
# Open Source Packages
java_gapic_assembly_gradle_pkg(
name = "{{type_only_assembly_name}}-java",
Copy link

Choose a reason for hiding this comment

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

This is consistent with the rest of the file so I think it's good in the context of the PR.
However, do we want to keep the it consistent with the names of regular packages? I don't see anything wrong with google-cloud-alloydb-connectors-v1alpha-java for types only packages. It may not matter for Bazel bot but the benefit I see is that

  1. Developers do not have to be aware of the differences between type-only and a regular package.
  2. It's a more predictable name when we want to test it locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type only packages don't always have a version in them, sometimes they are just google/shopping/type. In this case it would like google-shopping-type-java which isn't bad either.

Why don't we just use this name type_only_assembly_name variable here, and I will change the code in a separate PR to update the format of its value. It will impact other languages as well so best to keep in a separate PR.

Copy link

Choose a reason for hiding this comment

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

Yes, agree that it should be a different PR even if we want to change it.

java_gapic_assembly_gradle_pkg(
name = "{{type_only_assembly_name}}-java",
deps = [
":{{name}}_proto",
Copy link

Choose a reason for hiding this comment

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

It's probably my own lack of understanding, why do we need this for Java but not for other languages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea tbh. I just saw it in the same target for GAPIC libraries and copied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps because the protos are included in the generated code under the proto- directory?

@noahdietz noahdietz requested a review from a team as a code owner August 4, 2023 19:47
@noahdietz noahdietz requested a review from blakeli0 August 4, 2023 19:47
@noahdietz noahdietz merged commit 764f778 into googleapis:main Aug 4, 2023
4 checks passed
@noahdietz noahdietz deleted the java-types-assembly branch August 4, 2023 20:03
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.

None yet

3 participants