views:

944

answers:

7

I have a project (built from an AppFuse template) that requires Maven 2.2.1. So I upgraded to this (from 2.1.0) and set my path and my M2_HOME and MAVEN_HOME env variables.

Then I ran mvn eclipse:eclipseand imported the project into Eclipse (Galileo).

However, in the problems list for the project (and at the top of the pom.xml GUI editor) it says:

Unable to build project '/export/people/clegg/data/Workspace/funcserve/pom.xml; it requires Maven version 2.2.1

This persists whether I set Eclipse to use its Embedded Maven implementation, or the external 2.2.1 installation, in the Preferences -> Maven -> Installations dialog.

I've tried closing and reopening the project, reindexing the repository, cleaning the project, restarting the IDE, logging out and back in again, everything I can think of! But Eclipse still won't believe I have Maven 2.2.1.

I just did a plugin update so I have the latest version of Maven Integration for Eclipse -- 0.9.8.200905041414.

Does anyone know how to convince Eclipse I really do have the right version of Maven? It's like it's recorded the previous version somewhere else and won't pay any attention to my changes :-(

A: 

A common source of trouble (of this kind) is if you change global preferences and don't remember or know that you have enabled some project specific settings. At least it's a chance that the global setting is now set to use the external maven but the project setting is still set to 'embedded'.

Andreas_D
My project settings page for Maven doesn't allow me to set the Maven instance.
Andrew Clegg
A: 

M2Eclipse uses an embedded maven instance, not the maven instance you have installed on your system.

Jherico
m2eclipse can use an embedded maven instance **or** an "external" maven installation as the OP is reporting.
Pascal Thivent
A: 

Have you tried switching workspaces?

You can still reference the same project in the new workspace. This would provide about as much of a reset as you can do in terms of eclipses internal settings.

deterb
Sadly, even with a completely new workspace, the same thing happens.
Andrew Clegg
A: 

Try creating your eclipse project with mvn project:m2eclipse or use the maven import option under import project.

Richard Paul
A: 

Using m2eclipse, my fallback in these situations is to do Maven > Update Dependencies and then Maven > Update Project Configuration. The first is just me being supersticious, but the second will rewrite .project and .classpath.

As Pascal says about, m2eclipse can also be pointed at an external instance. I've done this in the past, though not at 2.2.1.

Dan

Dan Haywood
+2  A: 

Eclipse allows you to specify an external Maven installation. But there's a catch. :( Have a look at Windows > Preferences > Maven > Installations You will see a message like this:

Note: Embedded runtime is always used for dependency resolution, but does
not use global settings when it is used to launch Maven.
To learn more, visit the maven web page.

Translating to english, it means that Eclipse will continue to employ its internal Maven instance in order to perform some tasks. When you "Run As > maven install" it will run your pom.xml script employing the external Maven instance you specified but when Eclipse performs some of its internal stuff, it will continue to use the embedded Maven instance, whatever version it is.

In order to upgrade the internal embedded Maven instance, I'm not sure if you need to upgrade to Eclipse Galileo or if you need to upgrade your m2eclipse plugin.

Richard Gomes
Okay, this makes sense now. Unfortunately m2eclipse's embedded instance doesn't support Maven 2.2.1 yet (http://m2eclipse.sonatype.org/project-faq.html#16) and since it always uses the embedded version for the Maven project builder (http://m2eclipse.sonatype.org/project-faq.html#17) this means (presumably) incremental build and auto-build are unavailable in these cases. (Maybe could be worked around with a custom builder?) This is a case of me not reading the m2eclipse FAQ closely enough, although the salient point (the second link) is hidden in an unrelated question. Thanks!
Andrew Clegg
PS I'm already using Galileo (despite GanymedeWorkspace in the path) and the latest m2eclipse. Will edit question to make this clearer.
Andrew Clegg
A: 

If you are using a recent m2eclipse version, you can try this too:

<prerequisites>
    <maven>>=2.2.1</maven>
</prerequisites>

Notice the greater than in >=2.2.1. It works fine for me.

Richard Gomes