views:

155

answers:

4

My boss asked me to convert one of our projects to use Maven to build. So I created a pom.xml file and now Maven builds the project fine and runs all the tests and everything. "Fine", my boss said, "We don't need these any more" and he deleted the /libs directory from the project, and he deleted the JRE from the classpath. That's fine, it still builds in Maven, but Eclipse shows everything that was in the jre or in /libs as unresolved in the editor. Because of all the error indications, I'm seriously considering going back to vi. How can I get it so Eclipse can do its thing?

A: 

Use a Maven-Eclipse plugin.

Nick Veys
I'm using the plugin.
Paul Tomblin
+1  A: 

Oh never mind - I clicked the "Maven->Enable dependency management" and that fixed it. Don't know why I didn't think of it before.

Paul Tomblin
...so you are using m2eclipse :)
cetnar
+3  A: 

To create the Eclipse .classpath and .project files, do the following:

mvn eclipse:eclipse

This will create references to your local Maven repository, which means that you'll have to build at least once with Maven, so that it can download the files. I believe you also have to define an Eclipse classpath variable M2_REPO (at least, I have one defined, and can't see any other reason I'd have done that).

I'll assume your boss deleted the JRE entry from the Eclipse classpath, which was dumb but not as dumb as deleting your actual JRE directory. The Maven-build classpath file should include something appropriate, or you can go into the "Build Path" dialog and add the JRE via the "Libraries" tab.

kdgregory
A: 

You can use plugins as Nick mentions, but you can also solve this very simply by pointing eclipse to your local maven repository.

1) create a classpath variable, M2_REPO, in your workspace. It should point to something like "c:\Document and Settings\yourname.m2repo\ 2) Add the jars that you need.

These steps can also be automated with mvn eclipse:eclipse goal as well. The docs are here, I used it in the past but had some difficulties customizing it (for WTP and Spring configuration files under /.settings/ folder in the project)

Yoni