使用 Maven / Eclipse 停止自动构建
我们使用 Maven 和 Eclipse。我们有一个多模块项目,相当大。
Eclispe-Maven 集成似乎会自行决定何时对构建依赖模块做出反应,这很痛苦。
我已经打开了自动构建,但这似乎没有做出任何改变。
有一些操作,例如:删除资源或启动模块,将触发另一个模块的构建。
如何改变这种行为呢?我更喜欢根据需要手动调用maven。
We are using maven with eclipse. We have a multi module project, quite big.
Eclispe-Maven integration seems to decide by itself when to react building dependent modules, and that is being a pain.
I have turned on automatic building but that doesn't seems to make any changes.
There are certain actions such as: deleting a resource, or launching a module, that will trigger a build of another module.
How can that behavior be turned of? I prefer to call maven manually as required.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需转到顶部栏中的项目而不是取消选中“自动构建”。它将停止自动构建项目并节省您的宝贵时间。
Just go to Project in top bar than uncheck "Build Automatically". It will stop auto building the project and saves your precious time.
右键单击您尝试禁用自动 Maven 构建的项目,单击“属性”,然后单击左侧导航栏中的“构建器”。那里应该有一个“Maven Project Builder”,您可以取消选中以禁用它。
我不确定这是否正是您正在寻找的。我自己也从未真正进行过这样的操作,因此我无法谈论您可能遇到的任何副作用 - 尽管 Eclipse 本身会警告您:“这是一项高级操作。禁用项目构建器可能会产生很多副作用- 效果继续吗?”
假设您的项目处于某种版本控制中,请确保在执行此操作之前只有您的 pom.xml 而不是您的 Eclipse .project 文件或 .settings 文件夹位于源代码控制中。 (如果是这样,请确保不要将它们提交回来。)团队的其他成员可能不希望整个组禁用此构建器。 :-)
Right-click on the project you are trying to disable the automatic Maven builds for, click "Properties", then click on "Builders" from the left-hand navigation. There should be a "Maven Project Builder" there that you can uncheck to disable it.
I'm not sure if this is exactly what you're looking for. I also have never really operated like this myself, so I can't speak to any of the side-effects you may encounter - though Eclipse warns you about this itself: "This is an advanced operation. Disabling a project builder can have many side-effects. Continue?".
Assuming your project is in some sort of version control, make sure that only your pom.xml and not your Eclipse .project file nor .settings folder are in source control before doing this. (If so, be sure not to commit them back.) The rest of your team probably wouldn't want this builder disabled for the entire group. :-)
Ziesemer 的解决方案确实会停用 Maven 构建,但我认为当您在 Eclipse 中执行代码进行调试或测试时,它会带来一些相当不良的副作用。问题是某些资源将不会出现,因为构建不会按预期运行来复制和过滤它们。如果您像我一样,每次需要运行代码时往往忘记手动运行 Maven 构建,这会导致一些令人不快的幽灵错误并浪费时间。
关闭不需要的项目
当您拥有项目的工作副本时,执行
This will install all the dependencies in your local repository. Once done simply close the projects you do not need and only leave open the ones you are working on. this will force maven to resolve the projects from the local repository rather than the workspace. By doing so it will not trigger a build of dependencies.
停用工作区分辨率
您还可以通过单击项目并停用工作区分辨率来实现类似的效果。这将强制 Maven 执行存储库解析并绕过构建。但是,如果您更改多个项目,则必须确保它们首先安装到本地存储库,否则其他项目将看不到更改。可能还需要手动调整项目来解决依赖关系,特别是如果您不使用 SNAPSHOT 构建版本。
进一步拆分项目
另一种选择是将项目拆分为多个模块,每个模块都有自己的模块。这将创建一个更深的层次结构,它本身具有负面影响,但它允许您在环境中仅保留一组活动。再次确保您已将其他集安装到本地存储库,以便解决方案正常工作。
希望这有帮助。
Ziesemer's solution will indeed deactivate Maven building though I think it will come with some rather undesirable side-effects when you get to execute the code in Eclipse for debug or tests. Problem will be that some resources will not be present as the builds will not have run to copy and filter them as expected. this leads to some unpleasant phantom bugs and hours wasted if, like me, you tend to forget to run the maven build manually each time you need to run the code.
close unneeded projects
When you have a working copy of your projects perform a
This will install all the dependencies in your local repository. Once done simply close the projects you do not need and only leave open the ones you are working on. this will force maven to resolve the projects from the local repository rather than the workspace. By doing so it will not trigger a build of dependencies.
deactivate workspace resolution
you can also achieve a similar effect by clicking on a project and deactivate the workspace resolution. This will force maven to perform repository resolution and bypass the build. However if you change multiple projects you must ensure they are installed to the local repository first otherwise the other projects will not see the changes. May also require a manual jolt to the project to resolve dependencies especially if you are not using SNAPSHOT build version.
split project further
Another alternative would be to split your project in multiple modules, each having modules of their own. This will create a deeper hierarchy, which has negative side effects of it's own, but it will allow you to keep only one set active in your environment. Again, make sure you have installed the other set(s) to your local repository for the resolution to work correctly.
Hope this helps.