Search code examples
eclipsemavenm2eclipse

Maven eclipse - mutli project dependencies not appearing


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!


Solution

  • 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)