开发者

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开发者_Python百科, 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?


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜