I\'ve imported an existing maven project into Eclipse. I tried to set up the configurations for a JUnit test, and my project wouldn\'t come up as a testable project. When I
right click project --> properties --> maven --> lifecycle mapping --> check (skip maven compiler plugin) click ok now the build path appears . nw do the necessary changes
Problem was solved simply by deleting the project from my workspace, deleting all .project, .classpath files and .settings folders, and re-importing. I don't know why it didn't work the first time. Thanks for the help, everyone.
Make sure if you have M2 plugin in Eclipse, you have Maven 2.7 above installed in your system.
After that run
mvn eclipse:clean
then
mvn eclipse:eclipse
.
.classpath
and .project
will be created in your project folders.
Everything should be fine.
The Project nature is decided by the .project file in Eclipse, which also dictates to Eclipse about the Parent Source Code, and Test Folders.
Update/Modify the .project file as follows, using which We retain the Maven Compatibility and Java Nature of the Project.
.project.xml under the Eclipse Project folder
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>java-cgdk-en</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Install m2e and subclipse from the Eclipse Marketplace depending on what version of Eclipse you have. Then:
Window > Open Perspective > Other... > SVN Repository Exploring
.Checkout
.Configure > Convert to Maven Project
.It should now be recognized as both a Maven and a Java project (Maven and Java natures will have been added to the Eclipse .project file)
I'm using Version: Indigo Service Release 2 Build id: 20120216-1857
I also found that after I installed the Maven plugin that 'Project Explorer' - Right click on 'my project' did not list option "Maven" or "configure".
On reading the above, I tried doing the same on "Package Explorer" and to my surprise it worked. And now 'Project Explorer' works too!