views:

558

answers:

2

Hello, currently, I am developing web-apps using Eclipse. The build is done using Maven. The problem is that during compile time Eclipse is showing a lot of errors since there are a lot of missing jars. The final result is OK since the Maven is responsible for fetching these jars.

How can make the eclipse not fail the compilation?

I know I can just add the missing jars to the project classpath, but that's not what I'm looking for because I have a lot of projects, and the .classpath file of each project is a file common to all developers, so I would rather not to change it.

My question is therefor, is there a way to add a common classpath to all Eclipse projects without changing each project's classpath?

+3  A: 

Check out the m2eclipse plugin. It will read each project's POM and automatically fetch and add all dependencies to the classpath.

Jared Russell
+2  A: 

I use m2eclipse. It adds a classpath container to the .classpath file. This container is populated with the Maven dependencies by a Maven builder (added to the .project when the Maven nature is enabled) which processes the POM and downloads any artifacts (and sources if needed).

To enable the Maven nature (assuming the plugin is installed), right-click on a project and select Enable Dependency Management.

By default m2eclipse uses an embedded version of Maven to do its processing. This typically means a separate local repository and duplicate files on the box. You can configure it to use your standard Maven installation in Window->Preferences->Maven->Installations. Then adding the path to your Maven installation (normally the same as M2_HOME).


There is another Maven plugin for Eclipse called IAM (formerly called Q4E). IAM is an Eclipse integration project and has some promising features - it's worth keeping an eye on.


There is a comparison of the Eclipse Maven integrations, alongside the maven-eclipse-plugin (a goal that generates the Eclipse metadata files from the POM contents). I personally find the maven-eclipse-plugin more trouble than it's worth but it may suit your purposes and it is handy for generating the initial metadata if you have none checked into the SCM.

Rich Seller