如何阻止 m2eclipse 插件干扰命令行 mvn 构建?

发布于 2024-10-09 06:19:58 字数 471 浏览 0 评论 0原文

我在 Eclipse 中使用 m2eclipse 插件,以便可以导入 Maven 项目。该插件读取 pom.xml 并以 Eclipse 友好的方式整理项目中的依赖关系,因此我不会看到大量损坏的引用和错误。

我使用 Eclipse 进行代码开发,但我通常从命令行构建项目,例如“mvn clean install”。

不幸的是,当我这样做时,m2eclipse 会检测到磁盘活动并尝试重建工作区。这会干扰命令行构建,有时会导致竞争状况。例如,命令行可能处于清理阶段,但会失败,因为它尝试删除在工作区重建期间锁定的文件或目录。除了工作区重建非常慢之外,在失败的构建和浪费的 CPU 之间,我的构建过程比应有的时间长了 2-3 倍。

不能选择不使用 Eclipse(例如使用 Netbeans)或禁用 m2eclipse。除了这种行为之外,它是一个有用的插件。

所以我的问题是,如何阻止 m2eclipse 一直重建工作区?我可以调用手动刷新并以其他方式禁用此行为吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

咆哮 2024-10-16 06:20:01

问题是 Eclipse 检测到编译的资源已经消失并开始重建。

您不需要执行 mvn clean install ,而是执行 mvn install ,因为您的所有资源都已经是最新的。

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.

小嗲 2024-10-16 06:20:01

除了 dimitrisli 所说的之外,我建议对 eclipse 和命令行使用不同的输出目录。

您可以通过定义一个新的配置文件(例如“eclipse”)并将输出目录设置为 ${project.build.directory}/classes-eclipse 来完成此操作那个个人资料。

这样,即使您并行构建(从 Eclipse 和命令行),它们也不会相互干扰。

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.

不离久伴 2024-10-16 06:20:00

作为一个快速修复,您可以取消激活自动 Eclipse 构建,取消勾选 Project >自动构建

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文