Development Environment
-----------------------

I am working on a **Maven Java** client/server project that relies on **[Protocol Buffers](https://code.google.com/p/protobuf/) (protobuf)** for sending RPCs between the clients and server. I use **Eclipse for Java EE** as my primary IDE. Since I use Maven in my project, I am using the **m2eclipse** plugin for Eclipse. I configure my project in Eclipse to use the "Maven Nature".

The Problem
-----------

Basically, with the workspace setup described above, I am running into *INFINITE BUILD LOOPS* if Eclipse is configured to Build Automatically (which is the default: Project Menu --> Build Automatically). Whenever Eclipse spins off a build, the build will enter an infinite loop, often resulting in all my computer's CPU resources being consumed by Eclipse and eventually an error popup will appear in the IDE due to a memory overflow. What is happening is that all the generated Java code from the `.proto` files are continuously being built by Maven via the Eclipse build. Once the proto files are generated and compiled into a directory (in my case, `target/generated-sources`), the build of the proto files is immediately repeated. Even if I was to click on the stop button, the build would spin off again. The only way I can really stop the infinite build loop is to disable Build Automatically.

From looking through links on the web (see this [SOF post](https://stackoverflow.com/questions/8116283/eclipse-loops-endlessly-invoking-maven-project-builder), also listed below), one workaround was to disable the **Maven Project Builder** on my Eclipse project. To do so, I would have to open up the Eclipse project settings --> Builders --> deselect Maven Project Builder. Now, the infinite build loop will not happen, seemingly because it was m2eclipse's builder that was the culprit. However, I now lose a lot of useful functionality from this builder. Namely, I am not able to take advantage of automatic resource processing through m2eclipse, such as resource filtering. Note that projects using the Maven Nature have resource directories (`src/main/resources` and `src/test/resources`) excluded on the Java Build Path because of the expectation that the Maven Project Builder adds them to the classpath. So, one issue I run into with the Maven Project Builder disabled is that I cannot read resource files from the classpath in my tests. I would have to first run a manual maven build to get access to the resources (but once I refresh the project, I won't be able to find these classpath resources anymore). Or, I could change my project's Java Build Path, but that goes against the Maven Nature's defaults that work for me in all Eclipse Java projects besides ones relying on protobuf.

So, that all being said...
--------------------------

Does anyone have any idea how I can work around this problem? The Eclipse platform seems too mature to have this problem continue to sit around. I could always file an Eclipse bug that will collect dust, but perhaps it is not an Eclipse bug but rather an incorrect configuration on my side. Thank you so much in advance for the help.

Related Links
-------------

* SOF post about this issue: [Eclipse loops endlessly: Invoking 'Maven Project Builder'](https://stackoverflow.com/questions/8116283/eclipse-loops-endlessly-invoking-maven-project-builder)
* Open Github issue for the *maven-protobuf-plugin*: <https://github.com/igor-petruk/protobuf-maven-plugin/issues/16>