Paul Verest Paul Verest - 1 year ago 257
Java Question

Automatically generate Java from .proto with maven/m2e in Eclipse IDE

For my team, I'd like to configure maven/eclipse build to automatically generate Java code from

files (in a project that uses gRPC). Currently one needs to run
mvn generate-source
mvn protobuf:compile
(as in plugin usage page). Or what is the same add Run configuration to invoke maven goal

Whenever Eclipse Maven project is refreshed (Alt+F5) or IDE is restarted, project is rebuilt but without what should appear in
, thus turning project into red. So one need to generate and refresh project (F5). UPDATE Eclipse has needed source folders configured in

As I know that should be m2e connector, but I could only find one for the oldest Google
s plugin
, that is even not mentioned currently at

We use exactly referenced/recommended


that is:



Answer Source

Thanks to sergei-ivanov answer in, that gave link :

One need to download os-maven-plugin-x.x.x.Final.jar (the version as in your and put it into the <ECLIPSE_HOME>/plugins directory.

After that Eclipse will generate source on project clean, including after Maven -update project... (Alt+F5), but not after Project -> Build (or with default Build Automatically). Also on IDE start it will not compile.

Yes, that is illogical:

Project Clean will generate and compile Java source
Project - Build will not.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download