If I have a pom
hierarchy in which the superpom
calls multiple submodules which depend on one another, how can I list the build/compilation sequence based on dependencies? IOW, if the superpom has modules mod1, mod2, and mod3 and mod2 depends on mod3 and mod3 depends on mod1, then the sequence is mod1, mod3, then mod2. How can I list that order without complex XML parsing of data hierarchies from pom?
Maven searches for the dependencies in the following order: Local repository then Central repository then Remote repository. If dependency is not found in these repositories, maven stops processing and throws an error.
Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects. provided. This is much like compile , but indicates you expect the JDK or a container to provide the dependency at runtime.
There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.
groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org. apache. maven.
What you want to know is the so called reactor build order.
The reactor determines the correct build order from the dependencies stated by each project in their respective project descriptors, and will then execute a stated set of goals. It can be used for both building projects and other goals, such as site generation. (Source: old multi-module documentation)
It collects all modules to build, sorts the projects and builds them in order. It guarantees that any module is build, before it is required by other modules.
As far as I know, there is no direct way of creating only a list of these items, but the closest thing to just get the information is:
mvn validate
It will show your reactor build order on top:
~/parent$ mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] simple.parent
[INFO] simple.child
[INFO] simple.anotherchild
[...]
No additional work is performed, besides validating the project for correctness and that all necessary information is available.
For more information, see also the guide to working with multiple modules and this answer about what the maven reactor is.
Perhaps you're looking for the Maven dependency:tree option? You'll probably have to adjust the includes
to include only your modules. http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html
mvn dependency:tree -Dverbose -DoutputFile=tree.txt -DoutputType=text -Dincludes=com.mycompany.*
Improved version of @rhinoceros.xn:
mvn validate > validate.log
project_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.name -q -DforceStdout)
sed '1,/^\[INFO\] Reactor Build Order:/ d' validate.log | awk '/\[INFO\] -+</ {exit} {print}' | awk '{ print $2 }' | awk \!/^"$project_name"$/ | awk 'NF'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With