Is it possible to consider the multi-module Maven project in Eclipse as a hierarchy?

I want to configure one Maven module (parent POM) that displays all the child modules below 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 in the parent POM. The only way, apparently, to work with parent / child modules is to import each module as an independent project. We have 10+ child modules in our parent, and if I want to have multiple parent releases in the same workspace, it gets even worse because all child modules are displayed as projects.

+10
source share
4 answers

After a lot of research, including trying a similar approach with Netbeans, this is simply not possible. Parent POMs are processed as such, and each module must be loaded as a โ€œtop-levelโ€ project so that the IDE can recognize the source.

+3
source

Since Eclipse 4.5, you can see the multi-module maven project as a tree. To do this, you need to import all the modules as separate projects, then in the "Project Explorer" window, click on the "View Menu" (triangle button), select "Customize Presentation" and select "Nested Projects" on the "Content" tab. This tree view does not work in the Package Explorer view, only in the Project Explorer.

Customize View for Project Explorer "

Tree project structure

+10
source

If someone is looking for this here, this is what I did to have a hierarchical view.

In Eclipse, choose Windows> Show View> Project Explorer. When you are in the Project Explorer view, click on the drop-down icon and select Project View> Hierarchical

See this screenshot

0
source

Well, create a maven folder structure 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

`For example: 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 the project for the source and specify the path to it,

Then configure the build path, the source tab, add all the modules folders as the source. I consider this address to be all your requirements.

-1
source

Source: https://habr.com/ru/post/908154/


All Articles