How add protoc swagger plugin?


I have an existing build.gradle in a project, and I need to add to the build process invocation of the ProtoBuffer compiler’s plugin which would generate Swagger file from .proto file.

For myservice.proto file the command line to generate the Swagger file could look like this:

protoc -I. -I$GOPATH/src -I$GOPATH/src/ --swagger_out=logtostderr= true :. ./myservice.proto

I don’t know how to use ProtoBuffer (or any other) plugin to Gradle. How should I modify the build.gradle to get the Swagger file generation?