Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list active sub-modules in a Maven project?

Tags:

maven-2

I have a complex project where there are many directories that have POM files, but only some of which are sub-modules (possibly transitively) of a particular parent project.

Obviously, Maven knows the list of relevant files because it parses all the <module> tags to find them. But, I only see a list of the <name>s in the [INFO] comments, not the paths to those modules.

Is there a way to have Maven output a list of all the POM files that provided references to projects that are part of the reactor build for a given project?

like image 459
Emil Sit Avatar asked Sep 07 '10 20:09

Emil Sit


People also ask

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 is Maven Dependencymanagement?

What Is Maven Dependency Management? Dependency management in Maven allows teams to manage dependencies for multi-module projects and applications. These can consist of hundreds or even thousands of modules. Using Maven can help teams define, create, and maintain reproducible builds.

Can two Maven modules depend on each other?

Because modules within a multi-module build can depend on each other, it is important that the reactor sorts all the projects in a way that guarantees any project is built before it is required. The following relationships are honoured when sorting projects: a project dependency on another module in the build.


1 Answers

This is quite simple but it only gets the artifactId, from the root (or parent) module:

mvn --also-make dependency:tree | grep maven-dependency-plugin | awk '{ print $(NF-1) }'

If you want the directories

mvn -q --also-make exec:exec -Dexec.executable="pwd"
like image 147
Bonaparte Avatar answered Oct 04 '22 14:10

Bonaparte