停止使用 maven/eclipse 自动构建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7783721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:11:02  来源:igfitidea点击:

stop automatic building with maven / eclipse

eclipsemaven

提问by Rafael

We are using maven with eclipse. We have a multi module project, quite big.

我们在 Eclipse 中使用 Maven。我们有一个多模块项目,相当大。

Eclispe-Maven integration seems to decide by itself when to react building dependent modules, and that is being a pain.

Eclispe-Maven 集成似乎自己决定何时对构建依赖模块做出反应,这很痛苦。

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.

怎样才能改变这种行为?我更喜欢根据需要手动调用 maven。

采纳答案by amit sharma

Just go to Project in top bar than uncheck "Build Automatically". It will stop auto building the project and saves your precious time.

只需转到顶部栏中的项目而不是取消选中“自动构建”。它将停止自动构建项目并节省您的宝贵时间。

回答by Newtopian

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.

Ziesemer 的解决方案确实会停用 Maven 构建,但我认为当您在 Eclipse 中执行代码进行调试或测试时,它会带来一些相当不受欢迎的副作用。问题是某些资源将不存在,因为构建将无法按预期运行来复制和过滤它们。这会导致一些令人不快的幻象错误和时间浪费,如果像我一样,每次需要运行代码时往往忘记手动运行 Maven 构建。

close unneeded projectsWhen you have a working copy of your projects perform a

关闭不需要的项目当您有项目的工作副本时,请执行

mvn clean install
这将在您的本地存储库中安装所有依赖项。完成后,只需关闭您不需要的项目,只打开您正在处理的项目。这将强制 maven 从本地存储库而不是工作区解析项目。通过这样做,它不会触发依赖项的构建。

deactivate workspace resolutionyou 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.

停用工作区分辨率您也可以通过单击项目并停用工作区分辨率来实现类似的效果。这将强制 maven 执行存储库解析并绕过构建。但是,如果您更改多个项目,则必须确保首先将它们安装到本地存储库,否则其他项目将看不到更改。可能还需要手动震动项目以解决依赖项,尤其是在您不使用 SNAPSHOT 构建版本的情况下。

split project furtherAnother 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.

希望这可以帮助。

回答by ziesemer

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.

右键单击您尝试禁用自动 Maven 构建的项目,单击“属性”,然后单击左侧导航中的“构建器”。那里应该有一个“Maven Project Builder”,您可以取消选中以禁用它。

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?".

我不确定这是否正是您要找的。我自己也从来没有真正像这样操作过,所以我不能谈论您可能遇到的任何副作用 - 尽管 Eclipse 本身会警告您:“这是一项高级操作。禁用项目构建器可以有很多方面-效果。继续吗?”。

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. :-)

假设您的项目处于某种版本控制中,请确保在执行此操作之前只有 pom.xml 而不是 Eclipse .project 文件和 .settings 文件夹在源代码管理中。(如果是这样,请确保不要将它们提交回来。)您团队的其他成员可能不希望为整个组禁用此构建器。:-)