Thursday, May 20, 2010

m2eclipse (Maven 2 Eclipse Plugin) does not resolve project dependencies in Eclipse Ganymede/Eclipse Gallileo workspaces

This has bitten me too many times in the arse that I have finally decided to write myself a wiki on how to resolve this issue.

Reproducable on
Eclipse 3.4 Ganymede
Eclipse 3.5 Gallileo

Maven does not resolve all the dependencies and add the jar files in the workspace.

How to Resolve
1. Ensure that the following tags is in your .classpath file in your project (ensure that you have your JRE classpathenry above your maven classpathentry - exactly like the following):
< classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/ >
< classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/ >

2. Right click on your Project and navigate to Build Path -> COnfigure Build Path
3. In the 'Libraries' tab, click on 'Add Library' and click on 'Maven Managed Dependencies'
4. Click on the 'Maven Project Settings' link on the next window and ensure that the 'Resolve Dependencies from Workspace projects' is enabled.
5. Then, click on Windows -> Preferences -> Maven
6. Ensure that the 'Support multuple Maven modules mapped to a singe Eclipse workspace project' is enabled.
7. In that Maven dialog box, also ensure that 'install' is written in the 'Goals to run on project import:' textbox.
8. Now, right click on your Project and navigate to Maven
9. Ensure that the following are visible:
Disable Workspace Resolution
Disable Nested Modules
Disable Dependency Management
(The above three options mean that they are currently enabled. If, for example, it says 'Enable Nested Modules' rather than 'Disable Nested Modules', click on it to enable it.
10. Clean your project and build it.
11. Walla! You should see all your dependency jar files in the Maven Dependencies folder on your workspace. You can right click on your project -> Maven -> Update dependencies just to be sure too.

No comments:

Post a Comment

Thank you for your comment.