[英]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. 我在Eclipse中使用m2eclipse插件,以便可以导入Maven项目。 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.
该插件读取pom.xml并以Eclipse友好的方式整理出项目中的依赖项,因此我不会看到破烂的引用和错误。
I use Eclipse for code development however I usually build the projects from the command line, eg "mvn clean install". 我使用Eclipse进行代码开发,但是我通常从命令行构建项目,例如“ mvn clean install”。
Unfortunately when I do this, m2eclipse detects disk activity and attempts to rebuild the workspace. 不幸的是,当我这样做时,m2eclipse会检测到磁盘活动并尝试重建工作空间。 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.
除此之外,工作空间的重建非常缓慢,并且在失败的构建与浪费的CPU之间,我的构建过程比应有的长2-3倍。
It isn't an option to not use Eclipse (eg to use Netbeans), or to disable m2eclipse. 不选择不使用Eclipse(例如使用Netbeans)或禁用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? 所以我的问题是,如何始终阻止m2eclipse重建工作区? Can I invoke a manual refresh and otherwise disable this behaviour?
我可以调用手动刷新,否则禁用此行为吗?
作为快速解决方案,您可以停用自动的Eclipse构建,取消勾选Project > Build Automatically
The problem is that Eclipse detects that the compiled resources are gone and starts rebuilding. 问题是Eclipse检测到已编译的资源已消失并开始重建。
You should not need to perform mvn clean install
, but rather mvn install
, as all your resources are already up-to-date. 您不需要执行
mvn clean install
,而是执行mvn clean install
mvn install
,因为您的所有资源都已经是最新的。
In addition to what dimitrisli said, I would suggest using different output directories for eclipse and command line. 除了dimitrisli所说的以外,我建议对Eclipse和命令行使用不同的输出目录。
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. 为此,您可以定义一个新的配置文件(例如“ eclipse”),并将该配置文件中的输出目录设置为
<outputDirectory>${project.build.directory}/classes-eclipse</outputDirectory>
。
That way even if you build in parallel (from eclipse and from command line) they won't interfere with each other. 这样,即使您以并行方式(从Eclipse和命令行)进行构建,它们也不会相互干扰。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.