0

I have added the protoc compiler in my eclipse and now its recognize the .proto files but now I am struck to generate the java file from .proto file in eclipse. I searched so many references but not able to get this information more, if any one knows regarding this please help me advance thank you!!!

Noor
  • 41
  • 1
  • 9
  • Maybe this one helps http://stackoverflow.com/questions/4044891/linking-to-generated-java-protobuf-code-in-eclipse – SubOptimal Apr 12 '16 at 07:24
  • Thanks for your reply, now I am doing same as generate a java file from outside and link to eclipse but I need to generate the java file from example.proto file within eclipse, is it possible? – Noor Apr 12 '16 at 09:30
  • 1
    If your project build is done for example by `Maven` you could create a build step for the `generate` phase and later map this step to the build in eclipse with the `Lifecycle Mappings`. – SubOptimal Apr 12 '16 at 11:09
  • I don't believe you did thorough search as you can't tell difference between compiler and recognizing. Protoc is compiler that will generate ..java file, while to recognize you just need an Editor like https://marketplace.eclipse.org/content/minimalist-proto-files-editor-protocol-buffers-and-grpc. See also http://stackoverflow.com/questions/40426366/automatically-generate-java-from-proto-in-eclipse-ide – Paul Verest Nov 04 '16 at 15:28

1 Answers1

0

Add below plugin in your pom.xml and put your proto files in src>main>proto folder and then right click on ur project Maven>Update Project.... After that clean ur project.

<plugin><groupId>kr.motd.maven</groupId><artifactId>os-maven-plugin</artifactId><version>1.6.2</version><executions><execution><phase>initialize</phase><goals><goal>detect</goal></goals></execution></executions></plugin><plugin><groupId>org.xolstice.maven.plugins</groupId><artifactId>protobuf-maven-plugin</artifactId><version>0.6.1</version><configuration><protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}</protocArtifact><pluginId>grpc-java</pluginId><pluginArtifact>io.grpc:protoc-gen-grpc-java:1.4.0:exe:mac</pluginArtifact></configuration><executions><execution><goals><goal>compile</goal><goal>compile-custom</goal></goals></execution></executions></plugin>