Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a maven project module tree?

I'm looking for a quick way, for any given multi-module project, to show a quick overview of the project hierarchy including only the modules in the project, excluding external dependencies.

eg for a project

project root
+- A
   +- B
      +- C
   +- D 
      +- E
         +- F
+- G
   +- H

I would like to see a quick, single screen view for A-H (like it is depicted here) that gives me a fast digestible view to get an idea of a project structure. Ideally it would be command line output, not a platform specific solution (I note there is a tool for VisualStudio).

mvn dependency:tree is great but too verbose for this case, I suppose I could grep and cut the output apart but feels like there should be an easier way (ie another plugin).

like image 974
markdsievers Avatar asked Sep 13 '11 13:09

markdsievers


People also ask

How do I create a dependency:tree in mvn?

A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.

What is Maven dependency:tree?

A tree-based API for resolution of Maven project dependencies. Component entry point is DependencyGraphBuilder . © 2002–2022 The Apache Software Foundation.

How do I run a multi-module project in Maven?

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.


2 Answers

You can filter the dependency tree: http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html

So, if your group ID was com.foo.bar, you could get the projects in that group ID with:

mvn dependency:tree -Dincludes=com.foo.bar

Assuming all of your project's modules are within that group, that would cover your use case.

like image 181
Brett Porter Avatar answered Sep 28 '22 03:09

Brett Porter


You could try this module here: MavenStructurePlugin I had the same problem as you did and found it quite useful.

The output is pretty much what you seem to want:

            test
            |
            |__ a
            |
            |__ b
            |
            |
            \__ c
                |
                |__ d
                |
                |__ e
                |
                |__ f
like image 34
fgysin Avatar answered Sep 28 '22 02:09

fgysin