I want a single Maven module (parent POM) configured, that shows all of the child modules underneath it, but this does not seem to work correctly in Eclipse. For example, the open type (ctrl+shift+t) does not work because Eclipse does not detect source files under the parent POM. The only way parent/child modules seem to work is if I import every module as an independent project. We have 10+ child modules in our parent, and if I want to have multiple releases of the parent in a single workspace it gets even worse because all the child modules show up as projects.
6 Answers
Since Eclipse 4.5 it is possible to see a multi-module maven project as a tree. In order to do that you need to import all modules as separate projects, then on "Project Explorer" view click "View Menu" (the triangle button), choose "Customize view" and on "Content" tab tick "Nested Projects". This tree representation doesn't work in "Package Explorer" view, only in "Project Explorer".

- 6,285
- 3
- 29
- 36
-
4In Eclipse 4.7.2 Oxygen, its in -'View Menu' of Project explorer, -'Projects Presentation', -'Hierarchical' – liwevire Sep 06 '18 at 10:26
If any one is looking for this here is what i did to have a hierarchical view.
In Eclipse click Windows > show view > Project Explorer. Once you are on a Project Explorer view click on a drop down icon and click Projects Representation > Hierarchical

- 61
- 1
- 3
I solved this problem as follows:
Under the "Project Explorer" click on the "View Menu" (little triangle) and select "Filters and Customization..."
Under the "Content" tab tick "Nested Projects"
Finally, Under the "Pre-set filters" tab tick "Nested Projects: hide folders when projects is shown as nested" and "Nested Projects: hide-top-level project if shown as nested".
By doing that I come up with the following structure.

- 145
- 1
- 4
- 9
-
-
Works great! I just imported the parent project without having to import any of the subprojects. Then after changing to Hierarchical everything worked and classes from subproject modules became discoverable in Open Type dialog. – Magnus Dec 18 '20 at 00:19
After a lot of research, including trying a similar approach with Netbeans, it is simply not possible. Parent POMs are treating as such, and each module needs to be loaded as a "top level" project in order for the IDEs to recognize the source.
-
2Pls, reconsider the accepted answer as things have changed with time. – Mikhail Golubtsov Aug 02 '16 at 08:41
run mvn eclipse:eclipse
at parent's pom location. Go to eclipse --> File --> Import --> General --> Existing projects into workspace. It will import parent project and child modules as separate projects.

- 101
- 1
- 10
Well, create a maven folder structure in this way
ManiProject,
Module 1
Pom.xml </b>
Eg: '<project......
<parent> <artifactId>artifactIdMainProject</artifactId>
<groupId>groupIdMainProject</groupId>
<version>1.0-SNAPSHOT</version>
</parent>'
....
src
Main
test
Module 2 Pom.xml
Eg: '<project......
<parent> <artifactId>artifactIdMainProject</artifactId>
<groupId>groupIdMainProject</groupId>
<version>1.0-SNAPSHOT</version>
</parent>'
....
src
Main
test
.... Module N
Pom.xml
Eg: '<project......
<parent> <artifactId>artifactIdMainProject</artifactId>
<groupId>groupIdMainProject</groupId>
<version>1.0-SNAPSHOT</version>
</parent>'
....
src
Main
test
POM.xml
`Eg: artifactIdMainProject
<groupId>groupIdMainProject</groupId></b>
<version>1.0-SNAPSHOT</version></b>
....
<module> Module1 </module></b>
<module> Module2</module></b>
<module> ModuleN </module></b>
....
Now create a project in Eclipse by selecting create project fro the source and give the code path,
Then configure build path ,source tab, add all the module folders as source.I feel this address all your requirements.

- 29
- 4
-
This sort of defeats the purpose of the m2eclipse plugin doesn't it? I now have to configure the source and snapshot dependency jars manually. – Feb 10 '12 at 17:16
-
1If you dont want to do all these you will have to bare with multiple java projects in eclipse by using m2e plugin. – Naresh M Feb 13 '12 at 15:27