Reputation: 1254
I have a bunch of maven projects which all are part of a parent project. When I import the parent project into eclipse, I was expecting the child projects source folders to be listed in my parent project, however they are not. They also don't appear in the "Maven Dependencies" section.
Is this the correct behavior or am I missing something. If it is the correct behavior, then what is the best practice around doing this?
Should I be importing each project into eclipse and then editing the build path for my parent project to include them all? I really don't like this approach because I want to do everything through maven.
Note: I am not using mvn eclipse:eclipse
to generate my project files, I am using the maven plugin directly in eclipse IDE as: Import existing maven projects
Thanks!
Upvotes: 1
Views: 1101
Reputation: 445
Import your parent project then close it (right click on the project in the package explorer > close project
). Select it and go to file > import > maven > existing maven projets
here you should see the list of the child projects, select the wanted ones then finish
.
Now in your package explorer you should have :
A project parent-project
where you work on the pom-parent
and eventually on the src-parent
One project per child-project
where you work on the corresponding pom-child
and src-child
If some dependencies are missing try to update the projects (right click on the projects in the package explorer maven > update project
)
Normally you don't have to edit the build path in eclipse it must be handle by the maven nature of the project (the maven nature is often represent by a M
on the icons of the projects)
Upvotes: 1
Reputation: 3156
Normally, if you don't import "dependencies" projects, Eclipse simply uses the jars presents in your local repo (.m2).
However, I don't get what you mean by "I have a bunch of maven projects which all are part of a parent project".
Projects are not part of each other. And the child projects sources should not be listed in the sources folders. You only uses the bytecode.
If you want to "see all your sources" : However, you can have a complete "view" of the code if you export your sources as sources jars.
If you want to be able to debug across your projects : You then have to import all your projects in Eclipse. If a project is closed, Eclipse will use the jar like if the project was not there. If the project is open, it will use the project (not sure exactly how, but it works smoothly).
Upvotes: 0