imported maven project does not appear as java project. Shows folders
Asked Answered
D

16

22

I checked out the existing project source code from SVN to a folder in my system. Then I opened eclipse. Import Project-> Existing Maven Project.

It imported without issues. However, Project Explorer shows it as just folders instead of packages. (Like when we create a package and then add classes to it, it shows a different icon for package root). I opened Navigator and Package Explorer as well. But they are showing them as folders as well.

I tried:

mvn eclipse:clean
mvn eclipse:eclipse

on the root of the project. But it did not help.

Can anyone help on this one?

My folder structure:

ecs->
     ecs-ejb->
        src/java/main/com/xxx
        pom.xml
     ecs->ear->
        src/java/main/com/xxx
        pom.xml
     pom.xml
Dugan answered 28/5, 2013 at 19:16 Comment(2)
show your pom.xml pleaseExecutioner
Its a huge pom. Is there a specific section you want me to paste here?Dugan
S
21

Try to:

  1. Right click the project->Configure->Convert to Maven Project

---- Edit ----

If this doesnt work, it is likely that someone checked in their environment files into your SVN. If they checked in:

  • .project
  • .classpath
  • .settings/

They could be conflicting with your environment (different settings/plugins/versions of eclipse...). Try dropping your project, deleting the folder/files, then remove these files from SVN, and repeat your initial process. All of these files/folders will get generated during the import to eclipse.

---- Edit 2 ----

Per your recent edit to the question, you have a multi-module project. If you only did this on the parent project, then there is no source folder. So you wouldn't see it. You should:

  1. File->Import...
  2. Choose Existing Maven Projects, Next
  3. Set the Root Directory to ecs/ecs-ejb, Finish
  4. Repeat for all other modules.

In eclipse, each module of a multi-module maven project needs its own eclipse project.

Submariner answered 28/5, 2013 at 19:18 Comment(5)
I do not have that option. Instead I have different option.Dugan
Does your project have the correct maven folder structure? /src/main/java?Submariner
I do not see any of these files in the checked out folderDugan
Alternately, when adding maven projects, make sure to click 'add nested projects'. For one that didn't import, I found that New > Import Maven Project workedCurtain
Which file(s) needs to be deleted?Invade
I
17

Right click the project->Configure->Convert to Faceted Form

This solution worked for me

Ithyphallic answered 15/5, 2015 at 5:57 Comment(3)
Worked for me :)Spiritless
Worked for me as well.:)Judaize
Worked for me as well. To the point answer.Honolulu
D
8

Possibility is Module doesn't have .classpath.

Kindly right click on Module and Change Project fact as Java.

else

If you are using command Prompt. 1. mvn eclipse:clean 2. mvn eclipse:eclipse

else

Delete Project from Eclipse don't delete content from disk. remove .classpath and .project

Re-import as maven existing Project

Drupe answered 26/6, 2015 at 9:6 Comment(6)
"Change Project fact as Java" Where is this?Phraseologist
Hi @VivekChavda, mention are steps for "Project Facets" 1. Select Right Click on Module you like to work with. 2. Go to Properties 3. Project Facets 4. Right side you would see "select box" 5. Select as Java Let me know if need more descriptionDrupe
I don't see 'project facets'. Do you know if it won't show if it already sees it as a Java/Maven project? Not a big deal, since your mvn eclipse:eclipse suggestion seemed to fix things, which I appreciate.Phraseologist
May I know which IDE you are using?Drupe
Mars 4.5. It only gives the option to convert it to a Maven project.Phraseologist
So Directly go to command Prompt and try to execute mvn eclipse:clean mvn eclipse:eclipse This should resolve issueDrupe
C
2

Right Click->Maven->Update Project.

Above works perfectly fine for Eclipse Juno and solves the problem.

Chapnick answered 14/11, 2015 at 18:12 Comment(0)
O
2

You just need to change the nature of the project.

For MAC->

-> Right click on project
-> Properties -> Check Project Natures
-> Then add or remove accordingly if you are having a maven project then add Maven, add Java
Overthrow answered 31/8, 2020 at 14:13 Comment(0)
C
1

Try right click on project, Maven->Update Project... (or similar, the link name changes depending on version)

This works for me when adding new folders, but I have not encountered the problem when importing a project.

Cleon answered 28/5, 2013 at 19:20 Comment(0)
O
1

I had the same problem. I tried a lot of things that I read on internet but the only way that I found to solve my problem was exclude all of my workspace files (.metadata folder) and create another one.

After that, I imported a existing maven project and all my problems are gone.

Obrien answered 14/4, 2014 at 18:13 Comment(0)
P
1

I also faced a similar issue. I resolved it by downloading the correct apache maven plugins in the maven repository org / apache/ Maven/ plugins. IN my case, everything was working fine earlier and I had deleted .m2 repository completely. After that I started getting these issues with same iDE and newer IDE versions as well. The pom.xml showed error related to lifecycle mappings. On downloading the correct plugin, the workspace worked fine.

Pederast answered 26/6, 2015 at 8:10 Comment(0)
N
1

Delete the metadata folder. Checkout again but select "Checkout as a project configured using the New Project Wizard" instead of "Checkout as a project in the workspace". Then a New Project wizard will open, type maven there and select "Checkout Maven Projects from SCM" preferably or "Maven Project". It should work. Remember this step should be performed for Maven Projects only. For normal Projects just select Java Project or whatever relevant type Eclipse project it is.

Numerator answered 25/8, 2015 at 11:53 Comment(0)
D
1

Check and make sure you have eclipse pointing at a Java JDK directory instead of a Java JRE directory.

I had just installed eclipse and only the JRE was in the settings. I added the JDK path, changed it to the default and clicked on Maven -> Update project. Then the packages appeared in Package Explorer.

The hint that helped me figure this out is that when I tried to use the refactor to rename a class, it wouldn't do it, complaining that it wasn't a JDK.

Devorahdevore answered 26/10, 2017 at 0:1 Comment(0)
H
1

Instead of importing as Existing Maven Project, follow below steps
I assume that your folder has pom.xml, src/main and src/test.

Step 1: Right click > Create New > Java Project > Chose the project folder has pom.xml
Step 2: Right Click on Project > Configure > Convert to Maven project

Hideous answered 12/5, 2018 at 11:50 Comment(0)
C
1

I got it working using Proyect --> Properties --> Project Facets

In my case was a web project so I checked Java and Dynamic Web Module

Crist answered 5/6, 2018 at 13:47 Comment(0)
S
0

Right click the project, then click Configure -> Convert to Maven Project. If the packages still display as ordinary folders, then right click on the folder one level up (the one that is supposed to be the source folder), then click Build Path -> Use as a source folder.

Somatoplasm answered 28/5, 2013 at 19:30 Comment(1)
I do not have convert to maven project option. Instead I have convert to Faces, Plugin and JavaScript Project. I guess since I imported as Maven Project, I do not see that optionDugan
E
0

Here is my solution please close the Project Explorer at the left top and open again. (or) 1). Right Click on your miscellaneous project and choose project Explorer if available.

Eardrum answered 21/6, 2018 at 5:10 Comment(0)
G
0

Adding projects to working sets should help

try it -> right click the project -> Maven -> Assign Working Sets... -> Add projects to working sets

Git answered 20/6, 2019 at 11:4 Comment(0)
A
0

reimport the same project as maven. Click on "Show other specialized import wizards', then use maven.

Aftmost answered 4/5 at 4:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.