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

Use grpc-kotlin as protoc plugin (CLI) #42

Open
Emixam23 opened this issue Oct 18, 2019 · 1 comment
Open

Use grpc-kotlin as protoc plugin (CLI) #42

Emixam23 opened this issue Oct 18, 2019 · 1 comment

Comments

@Emixam23
Copy link

Hey !

I would like to know if this repo can be used as plugin for protoc? In fact I would like to generate the sources manually and using protoc, is that possible?

Thanks

@rouzwawi
Copy link
Owner

Hi @Emixam23. Yes this is possible on *nix type OSes currently by downloading the plugin artifact from the Maven repository.

Here's an example, using the test sources from the grpc-kotlin-test module.

mkdir -p example/src/main/{java,kotlin} && cd example
wget https://repo.maven.apache.org/maven2/io/rouz/grpc-kotlin-gen/0.1.2/grpc-kotlin-gen-0.1.2-jdk8.jar -O protoc-gen-grpc-kotlin.jar
chmod +x protoc-gen-grpc-kotlin.jar

# copy .proto sources into ./proto

protoc \
  -I=proto \
  --plugin=protoc-gen-grpc_kotlin=protoc-gen-grpc-kotlin.jar \
  --java_out=src/main/java \
  --grpc_kotlin_out=src/main/kotlin \
  ./proto/io/rouz/greeter.proto

Results in

tree .
.
├── proto
│   └── io
│       └── rouz
│           ├── greeter.proto
│           └── kvs.proto
├── protoc-gen-grpc-kotlin.jar
└── src
    └── main
        ├── java
        │   └── io
        │       └── rouz
        │           └── greeter
        │               ├── GreetReply.java
        │               ├── GreetReplyOrBuilder.java
        │               ├── GreetRequest.java
        │               ├── GreetRequestOrBuilder.java
        │               └── GreeterOuterClass.java
        └── kotlin
            └── io
                └── rouz
                    ├── greeter
                    │   ├── GreeterImplBase.kt
                    │   └── GreeterStubExt.kt
                    └── grpc
                        └── Adapters.kt

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

No branches or pull requests

2 participants