To build only the changed module and its dependents in a Maven multi-module project, use:
mvn -pl B -am clean install
-pl B
builds module B.
-am
also builds modules that depend on B (D, E).
Modules like A and C that didn’t change are skipped.
To skip tests in unchanged modules, add:
-DskipTests
If you want to automate detecting changed modules, use Git diff in your CI to build only those modules dynamically.
This minimizes build time by compiling and testing only affected modules.
checkout : https://rkoots.github.io/styleguide/