marcoferrer / kroto-plus

gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc
Apache License 2.0
494 stars 28 forks source link

Android and grpc-protobuf-lite support #25

Closed bob04619 closed 5 years ago

bob04619 commented 5 years ago

Hi, is the client gRPC generator suitable for Android?

I tested per example project and documentation instructions and it's leaking the full grpc-protobuf dependency on the runtime classpath.

+--- com.github.marcoferrer.krotoplus:kroto-plus-coroutines:0.2.2-RC1
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.11
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.11
|    |    \--- org.jetbrains:annotations:13.0
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.11 (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.1.0
|    |         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.11
|    +--- io.grpc:grpc-protobuf:1.15.1
|    |    +--- io.grpc:grpc-core:1.15.1
|    |    |    +--- io.grpc:grpc-context:1.15.1
|    |    |    +--- com.google.code.gson:gson:2.7
|    |    |    +--- com.google.guava:guava:20.0
|    |    |    +--- com.google.errorprone:error_prone_annotations:2.2.0
|    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
|    |    |    +--- org.codehaus.mojo:animal-sniffer-annotations:1.17
|    |    |    +--- io.opencensus:opencensus-api:0.12.3
|    |    |    |    \--- com.google.errorprone:error_prone_annotations:2.2.0
|    |    |    \--- io.opencensus:opencensus-contrib-grpc-metrics:0.12.3
|    |    |         +--- com.google.errorprone:error_prone_annotations:2.2.0
|    |    |         \--- io.opencensus:opencensus-api:0.12.3 (*)
|    |    +--- com.google.protobuf:protobuf-java:3.5.1
|    |    +--- com.google.guava:guava:20.0
|    |    +--- com.google.api.grpc:proto-google-common-protos:1.0.0
|    |    \--- io.grpc:grpc-protobuf-lite:1.15.1
|    |         +--- io.grpc:grpc-core:1.15.1 (*)
|    |         \--- com.google.guava:guava:20.0
|    \--- io.grpc:grpc-stub:1.15.1
|         \--- io.grpc:grpc-core:1.15.1 (*)
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3
marcoferrer commented 5 years ago

There shouldnt be any compatibility issues with the protobuf-lite runtime. To help out, I set up a protobuf-lite example configuration in the template project. If you encounter any issues please let me know.

You're right about the issue with the dependency polluting the classpath so Ill be sure to take care of that in the next release. In the mean time you can configure gradle to exclude the transitive grpc-protobuf.

dependencies {   
    implementation ("com.github.marcoferrer.krotoplus:kroto-plus-coroutines:$krotoplus_version"){
        exclude group: 'io.grpc'
    }
}

Thanks for the heads up!

bob04619 commented 5 years ago

Great, thanks. Our protobuf {} block for lite generation looks the exact same as what you ended up with. We'll run some client tests.

I don't quite envision how people will use your template if both the server and client use the same dependencies. e.g., For our stuff we use full io.grpc dependencies on server and *-lite on android. Also, as recommended by Google for the transport dependency we use this for Android:

implementation "io.grpc:grpc-okhttp:xxx"

and this for the server:

implementation "io.grpc:grpc-netty:xxx "

Thanks

marcoferrer commented 5 years ago

The example templates provided werent targeting the android runtime specifically. Thats why the client and server both use io.grpc:grpc-netty. The latest RC has removed the grpc-protobuf dependency from the coroutine runtime, so you shouldn't need to exclude it explicitly anymore.

davidbilik commented 5 years ago

Hello, do you have example android project that is setup using kroto?