stop automatic building with maven / eclipse

2020-07-03 02:22发布

问题:

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.

回答1:

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



回答2:

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

mvn clean install
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.



回答3:

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



标签: eclipse maven