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

后端 未结 5 1192
北荒
北荒 2021-01-11 09:37

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, th

相关标签:
5条回答
  • 2021-01-11 10:01

    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.

    0 讨论(0)
  • 2021-01-11 10:03

    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.

    0 讨论(0)
  • 2021-01-11 10:07

    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".

    0 讨论(0)
  • 2021-01-11 10:07

    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.

    0 讨论(0)
  • 2021-01-11 10:18

    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

    See this screen capture

    0 讨论(0)
提交回复
热议问题