Maven by Example - 6.5. Building the Multimodule Project |
|
With the ~/examples/ch-multi/simple-parent$ mvn clean install [INFO] Scanning for projects... [INFO] Reactor build order: [INFO] Simple Parent Project [INFO] simple-weather [INFO] simple-webapp Maven Webapp [INFO] ----------------------------------------- [INFO] Building simple-weather [INFO]task-segment: [clean, install] [INFO] ----------------------------------------- [...] [INFO] [install:install] [INFO] Installing simple-weather-1.0.jar to simple-weather-1.0.jar [INFO] ----------------------------------------- [INFO] Building simple-webapp Maven Webapp [INFO]task-segment: [clean, install] [INFO] ----------------------------------------- [...] [INFO] [install:install] [INFO] Installing simple-webapp.war to simple-webapp-1.0.war [INFO] [INFO] ----------------------------------------- [INFO] Reactor Summary: [INFO] ----------------------------------------- [INFO] Simple Parent Project .................. SUCCESS [3.041s] [INFO] simple-weather ......................... SUCCESS [4.802s] [INFO] simple-webapp Maven Webapp ............. SUCCESS [3.065s] [INFO] ----------------------------------------- When Maven is executed against a project with submodules, Maven first loads the parent POM and locates all of the submodule POMs. Maven then puts all of these project POMs into something called the Maven Reactor which analyzes the dependencies between modules. The Reactor takes care of ordering components to ensure that interdependent modules are compiled and installed in the proper order. NoteThe Reactor preserves the order of modules as defined in the POM unless changes need to be made. A helpful mental model for this is to picture that modules with dependencies on sibling projects are "pushed down" the list until the dependency ordering is satisfied. On rare occasions, it may be handy to rearrange the module order of your build — for example if you want a frequently unstable module towards the beginning of the build. Once the Reactor figures out the order in which projects must be
built, Maven then executes the specified goals for every module in the
multi-module build. In this example, you can see that Maven builds
NoteWhen you run Maven from the command line you’ll frequently want
to specify the |