I have a maven project, that I'm working on Eclipse.
I use maven eclipse:eclipse to generate the classpath, but ... it NEVER adds the classpath on the eclipse project. I've tried the maven-eclipse-plugin, I've tried the M2Eclipse plugin, but it doesn't matter what I do, I can't get the classpath entries to start working. I have many build errors, even thought the maven builds the ear perfectly.
Any guidelines?
Thanks for any answer!
UPDATE: Here's my root classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="core/src/main/resources"/>
<classpathentry kind="src" path="client/src/main/java"/>
<classpathentry kind="src" path="client/src/main/resources"/>
<classpathentry kind="src" path="junit_server/src/main/java"/>
<classpathentry kind="src" path="initializer/src/main/java"/>
<classpathentry kind="src" path="initializer/src/main/webapp"/>
<classpathentry kind="src" path="site/src/main/webapp"/>
<classpathentry kind="src" path="core/src/test/java"/>
<classpathentry kind="src" path="core/src/test/resources"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="var" path="M2_REPO"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
UPDATE2: This is my .project:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>coreisp_back</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
You need to add the extra source folders to the pom.xml with the build-helper-maven-plugin. Then run
mvn eclipse:clean eclipse:eclipse
For example this pom.xml ..
Generates this .classpath
Make sure the folders exist, if the path is incorrect they wont be added. Look for this in the maven log.
[INFO] skip non existing resourceDirectory /tmp/artifact/src/main/resources
My team found the eclipse maven plugins to be unstable, opting to create our entire eclipse config through maven.
This is relying on m2eclipse. When you do that, all your dependencies are handled by maven/m2eclipse, so your .classpath becomes very minimal.
In term of project architecture, you want one eclipse project per maven pom. Each project .classpath contains only the sources, JRE and maven injection:
(adjust depending where your sources are).
I suspect your many errors come from duplicate entries in the dependencies because you inject them both manually (additional .classpath entries) and through maven.
You'll also want to verify local workspace resolution in m2eclipse are enabled (should be on by default).
In addition to the most voted answer, you can still be left with a broken project, no 'Maven Dependencies' (Kepler) and no classpath resolution.
In my case my local maven repository settings.xml got deleted when a third party sdk updated itself, after a restart eclipse seemed to clear out the reference to that settings.xml file.
Once I put the file back and referred to it in Maven > Installations > Global Settings: /home/andy/.m2/settings.xml , cleaning each project kick-started all the necessary classpath resolution. just sharing.
For me, the resulting files looked like:
.classpath
.project
The setup generated by the Maven Eclipse plugin is not compatible with m2e/m2eclipse. If you want to use Maven and Eclipse together your best course is to remove any modification to your setup generated by the maven eclipse plugin and use m2e to import your Maven project.
a problem I run into is after converting a project to maven I need to clear the Run Configuration as conversion does not update the classpath to configure maven-dependency classpaths.