Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to print the structure of a multi-module maven project?

I'm facing a rather large multi module maven project. I would like to see how the root (parent) project is composed out of subprojects/ child projects in the form of groupId:artifactId (possible with some identation to reflect the hierarchy.

Of course I can write my own plugin to get this printout, but I reckon that there must be something available of the shelf.

like image 670
Sjaak Avatar asked Apr 19 '12 12:04

Sjaak


People also ask

What is the difference between Maven module and Maven project?

a maven module is like a maven "sub-project". a maven project includes 1 or more modules. more info here. Typically, a module generates a single artifact (jar, war, zip, etc), although this is not always true.

What is packaging type of parent project in a multi module Maven project?

The parent maven project must contain the packaging type pom that makes the project as an aggregator. The pom. xml file of the parent project consists the list of all modules, common dependencies, and properties that are inherited by the child projects. The parent pom is located in the project's root directory.

What is a multi module Maven project?

A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.

What benefits does multi module project structure have give the key benefits of the multi module project structure?

Advantages of a Multi-Module ProjectIt provides a great ability to build all sub-modules only with a single command. We can run the build command from the parent module. While building the application, the build system takes care of the build order. Deployment of the applications gets very convenient and flexible.


1 Answers

Hello late answer but I have added a plugin into maven repository:

<dependency>
    <groupId>org.qunix</groupId>
    <artifactId>structure-maven-plugin</artifactId>
    <version>0.0.1</version>
</dependency>

To run the plugin you will need to add into your pom as below:

<build>
        <plugins>

            <plugin>
                <groupId>org.qunix</groupId>
                <artifactId>structure-maven-plugin</artifactId>
                <version>0.0.1</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>
                                printModules
                            </goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

then output will look like:

   [INFO] --- structure-maven-plugin:0.0.1:printModules (default) @ test ---
[INFO] 

Project structure (all modules):



                test
                |
                |__ a
                |
                |__ b
                |
                |
                \__ c
                    |
                    |__ d
                    |
                    |__ e
                    |
                    |__ f

If you want to print all files insted of modules use the goal: printAll or if you want just folders use the goal:printFolders. <inherited> means dont execute plugin also in modules and <ignore> mean skip this files using regex pattern.

EDIT: there is never version you can pull from github: https://github.com/buraksarac/MavenStructurePlugin

like image 193
HRgiger Avatar answered Oct 06 '22 00:10

HRgiger