Understanding project aggregation
A key difference between inheritance and aggregation is that, aggregation is defined with a top-down approach, whereas inheritance is defined the other way around. In Maven, project aggregation is similar to project inheritance, except that the change is made in the parent pom instead of the child pom.
Maven uses the term module to define a child or subproject, which is part of a larger project. An aggregate project can build all the modules together. Also, a Maven command run on the parent pom or the pom file of the aggregate project will also apply to all the modules that it contains.
How to do it...
Open a project that has aggregation; in our case
project-with-aggregation
. This has a subfolder namedaggregate-child
, which is the module that is aggregated by the parent project.Update the parent pom as follows:
<groupId>com.packt.cookbook</groupId> <artifactId>project-with-aggregation</artifactId> <packaging>pom<...