locka
locka

Reputation: 6029

How do I stop the m2eclipse plugin interfering with command line mvn builds?

I use the m2eclipse plugin in Eclipse so that I can import a Maven project. The plugin reads the pom.xml and sorts out the dependencies in the projects in an Eclipse friendly way so I'm not looking at a sea of broken references and errors.

I use Eclipse for code development however I usually build the projects from the command line, e.g. "mvn clean install".

Unfortunately when I do this, m2eclipse detects disk activity and attempts to rebuild the workspace. This interferes with the command line build and sometimes results in a race condition. For example the command line might be in its clean phase but fails because it tries to delete a file or directory which is locked during the workspace rebuild. Aside from that workspace rebuilding is incredibly slow, and between failed builds and wasted CPU my build process is 2-3x longer than it should be.

It isn't an option to not use Eclipse (e.g. to use Netbeans), or to disable m2eclipse. It is a useful plugin except for this behaviour.

So my question is, how do I stop m2eclipse from rebuilding the workspace all the time? Can I invoke a manual refresh and otherwise disable this behaviour?

Upvotes: 5

Views: 1071

Answers (3)

m_vitaly
m_vitaly

Reputation: 11952

In addition to what dimitrisli said, I would suggest using different output directories for eclipse and command line.

You do this by defining a new profile (ex. "eclipse") and set the output directory to be <outputDirectory>${project.build.directory}/classes-eclipse</outputDirectory> in that profile.

That way even if you build in parallel (from eclipse and from command line) they won't interfere with each other.

Upvotes: 0

dimitrisli
dimitrisli

Reputation: 21381

As a quick fix, you could deactivate automated Eclipse builds unticking Project > Build Automatically

Upvotes: 2

Robert Munteanu
Robert Munteanu

Reputation: 68268

The problem is that Eclipse detects that the compiled resources are gone and starts rebuilding.

You should not need to perform mvn clean install , but rather mvn install, as all your resources are already up-to-date.

Upvotes: 0

Related Questions