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

feat: add Kotlin Android and JVM protos #245

Merged
merged 3 commits into from
Jan 9, 2024
Merged

feat: add Kotlin Android and JVM protos #245

merged 3 commits into from
Jan 9, 2024

Conversation

nand4011
Copy link
Contributor

@nand4011 nand4011 commented Nov 20, 2023

Copy configuration from the grpc kotlin stub lite example to generate kotlin code for android and jvm.

Remove old kotlin messages generation and publication.

I needed to include google/protobuf/descriptor.proto because there is no lite version of google common protos:
protocolbuffers/protobuf#7331
protocolbuffers/protobuf#1889

There's no proto-google-common-protos-lite because there is no API/ABI stability guarantees for lite codegen. You need to generate all lite protos with the same version of the generator, so pre-built libraries doesn't make much sense. You can't ship a library that has pre-built lite protos, unless you can control the version of protobuf the app uses (which could be the case within a single company, but not for anything that goes on Maven Central). If you use protobuf only internally to your library, you can shade protobuf, but obviously that bloats its size so isn't really much of a help.

That comment was made last week, so this is an ongoing issue. I don't see a good way of guaranteeing that libraries that use java-lite/kotlin-lite won't clash with each other other than trying to shade the generated code.

Copy configuration from the grpc kotlin stub lite example to generate
kotlin code for android and jvm.

Remove old kotlin messages generation and publication.
kotlin/android/build.gradle.kts Outdated Show resolved Hide resolved
kotlin/android/build.gradle.kts Show resolved Hide resolved
@nand4011 nand4011 marked this pull request as ready for review January 8, 2024 18:28
@cprice404
Copy link
Collaborator

@nand4011 are the issues in the original PR description resolved?

publications {
create<MavenPublication>("maven") {
from(components["java"])
artifactId = rootProject.name + "-android"
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do the final coordinates end up looking like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

software.momento.kotlin:client-protos-jvm and software.momento.kotlin:client-protos-android. I matched the existing pattern for the java protos: software.momento.java:client-protos.

@nand4011
Copy link
Contributor Author

nand4011 commented Jan 8, 2024

@cprice404 Both issues are still open. There has been no comment on the webhook bug I reported with the protobuf project. I was hoping that would be fast enough that it would be fixed before releasing this, but no dice.

If necessary, I can leave the old kotlin protos in place. They are under a different module and they can still be published to the internal repo without disturbing this work.

@cprice404
Copy link
Collaborator

@cprice404 Both issues are still open. There has been no comment on the webhook bug I reported with the protobuf project. I was hoping that would be fast enough that it would be fixed before releasing this, but no dice.

If necessary, I can leave the old kotlin protos in place. They are under a different module and they can still be published to the internal repo without disturbing this work.

I don't think you need to maintain the old version, I just need to understand the implications here before we merge.

It sounds like:

(a) we had to vendor some google protos, and maybe if other projects are trying to use our SDK and also use other grpc libraries, there may be a conflict between the 2 versions of said protos? and
(b) I'm not sure understand the current state of this PR w/rt the "webhook" collision. Did you just skip the webhook APIs in the kotlin proto generation in this PR?

Only generate Java request and response classes. The Kotlin methods use
the Java requests anyway, so there is no reason for the Kotlin request
classes to exist. This sidesteps the webhook kotlin bug.
@nand4011
Copy link
Contributor Author

nand4011 commented Jan 9, 2024

I discovered that we don't need the kotlin version of the webhook class, so there is no issue there anymore. I updated the pr.
The descriptor.proto and other google protos we included are still a potential issue. A user that is making an android project that includes multiple libraries that make grpc calls could run into problems. I need to experiment to make sure it is an issue, but it would only affect a narrow slice of users.

@nand4011 nand4011 merged commit 6ff8f7e into main Jan 9, 2024
7 checks passed
@nand4011 nand4011 deleted the kotlin-android branch January 9, 2024 00:12
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.

3 participants