So I confidently when to the eclipse option to import existing maven projects ... all went well until I opened the project & tried to build it. when I saw this error:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources (execution: default-resources, phase: process-resources) pom.xml /test line 6 Maven Project Build Lifecycle Mapping Problem
This was not very welcome and the eclipse autofix options did not fix the issue.So I turned to Slastdot & found a post (http://stackoverflow.com/questions/7638562/import-maven-project-to-eclipse-and-fix-the-errors) but the top solution to to do a project update did not work.
So to fix it I followed a secondary solution (after deleting the .project file previously created) ...
- Open the project folder in a command prompt;
- run command
mvn eclipse:eclipse
- Open the project using eclipse;
- Set project properties "configure-->Convert to Maven Project"
My experience is that this works nicely.... ALMOST!
The issue is that eclipse may not correctly pick up the maven dependencies.
This is because the .classpath file does not include values on the paths as follows "<attribute name="maven.pomderived" value="true"/>".
This for a simple project means that you needs to convert your .classpath file from this:
to this:
Now this should pick up your MAVEN dependencies.
Other references:
The issue is that eclipse may not correctly pick up the maven dependencies.
This is because the .classpath file does not include values on the paths as follows "<attribute name="maven.pomderived" value="true"/>".
This for a simple project means that you needs to convert your .classpath file from this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
</classpath>
to this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/java" including="**/*.java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
</classpath>
Now this should pick up your MAVEN dependencies.
Other references: