I have a Maven parent project which has multiple child/modules...I have the following pom.xml for the main/parent;
<modules>
<module>Main-Ear</module>
<module>Sub-Web</module>
<module>Sub-Ui</module>
<module>Sub-Services</module>
<module>Sub-SSO-Login</module>
</modules>
However, I find the actual build order to be different... After build, the actual order looks like;
Main
Sub-Services
Sub-SSO-Login
Sub-UI
Sub-Web
Main-Ear
Where exactly does Maven take the build order from in this case?
You can't manually control the build order:
From Maven project documentation (Guide to Working with Multiple Modules):
Reactor Sorting
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
- a plugin declaration where the plugin is another modules in the build
- a plugin dependency on another module in the build
- a build extension declaration on another module in the build the order declared in the element (if no other rule applies)
Note that only "instantiated" references are used - dependencyManagement and pluginManagement elements will not cause a change to the reactor sort order
Maven not taken the module building order from what we define in the main pom.xml. Maven decide the order by considering module dependencies with each other modules.
In your case definitely Main-Ear should build last.
Let's consider following example.
I have module A, B and C. Module A has dependency from module C and B while module C has dependency from module B. Then maven building order will be
B
C
A
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