How do I disable maven build when using Maven 2.0 integration for eclipse? - eclipse

How do I stop the "Maven 2.0 integration" plugin from running maven build, while keeping "build automatically" checked?
I'm pretty sure it used to be some check box to disable maven build before, but after upgrading Ubuntu; eclipse seems to have been updated in the process, and now I cannot find any way to turn off the maven build. The maven build takes literally minutes (about 5 minutes or so), while just running java build used to finish in seconds.
Is it no longer possible to disable it or have they just hidden it well?
If it's not possible, will eclipse be able to compile my maven project without the plugin?
(Trying to google for a solution the closes I got to an answer was several archives of this old post where the answer essentially were "You should be able to disable Maven builder in project preferences..." which doesn't really help because I cannot find any on/off settings there)

To disable the Maven Project Builder, right-click on your project then Preferences > Builders and uncheck the Maven Project Builder (you cannot modify the default maven builder).
alt text http://www.imagebanana.com/img/fikqaidv/screenshot_010.png
If this removes "too much" things, you can maybe create your own custom Maven builder. Click New, select Maven Build and configure it as you want.
alt text http://www.imagebanana.com/img/rwkmm7jb/screenshot_010.png
Disabling it seems to stop eclipse from knowing about the related projects causing the java build to fail. Is there a some sort of dummy, no-operation goal I can use for auto build goals?
I guess you would have to add the related projects in the Project References (or to uncheck Resolve dependencies from Workspace projects).
Is there a way to disable it for all 6 related projects in the workspace simultaneously?
I don't think so.
At the end, all this tweaks looks like ugly hacks. If you're not satisfied by the m2eclipse plugin, maybe you should use the maven-eclipse-plugin instead (i.e. run mvn eclipse:eclipse) instead to generate the .project and .classpath files and import your projects as Existing Project into Eclipse.

Related

How do I get my Eclipse-Maven project to automatically update its classpath when I change a dependency in my pom.xml file?

I’m using Eclipse Mars with Maven (v 3.3). When I update a dependency in my pom (change the version), my Eclipse-Maven project doesn’t pick it up, even when I right click my project, and select “Maven” -> “Update Project.” I know this because I do not see compilation errors in the Eclipse Java editor that I see when I build the project on the command line using
mvn clean install
When I remove the project from the workspace and re-import it, then things get back to normal. However this is a cumbersome process. How do I get my Maven-Eclipse project to automatically detect changes in my pom and update the project libraries appropriately?
And yes, in the “Project” menu, “Build Automatically” is checked.
When you import the project into Eclipse, use Eclipse's own built-in Maven support (aka, m2e). I recommend against using mvn eclipse:eclipse as it doesn't give the best results (as you're seeing). Maven is a build and dependency management tool, not an IDE; expecting it to manage IDE-specific stuff is silly, in my opinion (I realize the Maven team thinks differently, that Maven should be responsible for managing your IDE, but that's nonsense).
So if you have the project available on your system, delete any Eclipse-specific files (typically just .classpath, .project, and folder .settings), they were generated by mvn eclipse:eclipse and you don't want them interfering with the "proper" import process described here. Then inside Eclipse, use File > Import > Maven > Existing Maven Projects to import the project. That should result in better integration between Eclipse and maven, including automatically updating the Eclipse build path when the pom is changed.
As a quick check, after doing the import that way, you should see a group called Maven Dependencies in the Libraries tab of the project's Build Path (in Properties dialog). Like this:
If you want the Eclipse project configuration to be automatically updated every time the pom is changed, there's a (experimental) setting for that under Preferences > Maven. Be aware that doing so might not be desirable, though - as mentioned in this feature request, it's a somewhat lengthy process that touches a bunch of stuff in the Eclipse Project; doing that automatically on every pom.xml change could end up being more trouble than it's worth.
Three Mandatory checks you should do for automatic update in your classpath
Your Repository is not in-sync with your Eclipse IDE, Please check the below settings in your IDE.
Right Click your any POM.xml from your IDE and check for the Maven profile which should be auto-activated. Also offline and Force update check box shouldn't be enabled. Please refer the below image.
Always check for your user settings which should reflect your local maven settings.xml, as shown in the below figure.
After performing all these checks, refresh your Eclipse Work-space to get these changes reflected.
Eclipse should be updating your classpath. If it's not, that implies something is going wrong.
It's hard to say what the problem could be exactly without knowing more about your project's pom.xml. More information might be necessary to solve the issue, but I'll just make a stab in the dark:
Open the .project file in your project's root folder and check the ordering of builders and natures there. It might be possible that some other nature on the project is also causing maven2Nature to fail. Move maven nature up and see if that helps any.
Alternatively you might be thinking that Eclipse does not update your dependencies because it does not add some some error indicators in the project that should be there with new dependencies. If that's the case try cleaning the current project (project>clean...). Maven in Eclipse does not necessarily trigger a full rebuild when dependencies are updated.
If none of this works, closing/opening the project might solve the issue quicker than re-importing.
What you wrote, should work. Did you check this:
does "pure" mvn install from terminal see your changes in POM?
maybe some Maybe plugin is buggy, cached some dependencies in target, and mvn clean install is needed
you can run Eclipse in a new workspace, and import your project there, sometimes it helps in case of such strange problems
instead of importing Maven project to Eclipse via m2eclipse, you can try to create Eclipse files via the old mvn eclipse:eclipse and see what happens then
does it work well when you try to import your Maven project to other IDE, the free IntelliJ Community Edition for example?
As a last resort, you can delete your current Eclipse installation and install a new version. When you add several plugins, they might interfere with one another and create weird behavior. After you do that, do not import your Maven project into your workspace, but rather create a new one and copy and paste the files that you had.

the "build automatically" and maven in Eclipse

in Eclipse, when Maven is enabled, there is a pom.xml file to build with Maven. And also, Eclipse has a "build automatically" option in it's project menu.
Is the "build automatically" automatically build with Maven, or we need uncheck it, because when Maven is enabled, we don't need the Eclipse build in build system anymore?
Eclipse's m2e will run the plugin goals it has lifecycle bindings for. I don't know (and I'm unable to find) what specific phases are run, but from experience I know that:
for normal operation, at least compile gets executed.
for executing tests (e.g. JUnit test cases), at least test-compile gets executed.
Note that it doesn't have all possible bindings, and going around that problem is sometimes problematic. So, usually, having both should run fine, and in fact will avoid some incongruities due to the compiled state not updating while you code.
However if you have plugins that are ignored by m2e, you should actually shut down "Build Automatically" off when you need to be certain your build completes correctly.
For example, using the Maven Properties plugin, if you have not provided a binding and set m2e to ignore, you will have resources with out-of-whack property values. The problem can especially occur when you do a "Maven" build (from the right-click context menu for example), and then do a change in your code and save it.
You need both. Here is why:
Eclipse built-in compiler is used for incremental compilation - when you save your code, for example. But full build of the project is done using maven and project configuration in pom.xml.

Disable Maven Workspace Resolution in Eclipse Globally

I'm currently working on multiple large webapps(each webapp when being run actually contains 3-7 eclipse projects) in Spring Tool Suite on a Mac. Every imported webapp has several errors after import and project validation complete. The maven builds will fail continually until I right click on every project associated with the given webapp and select Maven -> Disable Workspace Resolution. I can think run a maven clean, maven update, and maven build to clear out all the errors.
If there a way to disable Maven Workspace Revolution in my eclipse settings/preferences so that it's a global one time setting that tells every project in the eclipse workspace not to use Workspace Resolution?
Below are some screenshots I took to hopefully provide all the relevant details such as version numbers.
I just recently switched from using eclipse with add-ons to using the preconfigured Spring Tool Suite, so the install is only a few weeks old. It should be hopefully the most up to date versions of most plugins.
It can be achieved much faster by doing a Search (Ctrl-H) for resolveWorkspaceProjects=true for files of name org.eclipse.m2e.core.prefs, with the scope set to Workspace, and Replace set to resolveWorkspaceProjects=false.
I don't believe there is a global setting to do this automatically.

m2eclipse: How do I configure parameters to the Maven Project Builder?

In Eclipse Helios with m2eclipse installed, Build Automatically is on by default. I can see that this uses some sort of incremental Maven builder under the covers (for Maven projects, obviously).
How can I customize the Maven builder so that, for example, I can supply it with some -D options? Specifically, I want my automatic, incremental Maven builds to be run with -Dmaven.buildNumber.doCheck=false. I see nowhere where I can actually affect the configuration of the m2eclipse-supplied Maven builder.
I am aware that I can create a run configuration and then explicitly build my project using Run As..., but I don't want to pursue that path. I want to customize the way my project is built when I choose the Build All command from the Project menu. I also want these customizations to be in effect when an automatic build is triggered.
I don't particularly want to add settings to my ~/.m2/settings.xml file because I don't actually want my command-line Maven installation to pick up these settings outside of Eclipse.
Thanks in advance for any help here.
At the moment, you need to put the settings in a profile and then trigger that profile. The M2E gang has removed the settings that used to be useful for this purpose.
You can make a custom settings.xml in a separate location and configure THAT in the m2e prefs.

How can I configure additional eclipse settings with m2eclipse?

With the maven eclipse plugin, I can configure checkstyle or sonar configurations by adding the necessary invocations to the pom.xml and calling "mvn eclipse:eclipse" to create the project configuration.
Some members of my team want to just use "Import Maven project" and therefore don't get the benefits of the project preconfigurations. Is there a way to provide the same (or similiar) hints to m2eclipse?
What I want to accomplish is that people simply "Import Maven Project", and they automatically get a project preconfigured with the correct checkstyle configuration (which is possibly downloaded from somewhere as defined in the POM) without having to manually go into the project preferences and click around a lot. That somehow defeats the purpose of automatic project generation :-)
There are more detailed answers to this topic in Can I Configure m2eclipse through pom.xml?: Completely automatic configuration can only be achieved with a ProjectConfigurator. But there is a solution based on AntRun and XMLTask even for FindBugs and Sonar. It needs manual triggering only once after checkout.
This is doable by writing custom ProjectConfigurator (as mentioned in this thread). And it looks like somebody plublished some of them (for Checkstyle, PMD, FindBugs) in the m2e-extensions project.