How to list active sub-modules in a Maven project

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?

Best Answer

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"