Maven Project Inheritance
Assuming a project is divided in several modules, each module is a maven project in itself. The parent's pom.xml would be like:<project> <modelVersion>4.0.0</modelVersion> <groupId>com.mygroupid</groupId> <artifactId>myprojectparent</artifactId> <version>1.0.0</version> </project>
<project> <parent> <groupId>com.mygroupid</groupId> <artifactId>myprojectparent</artifactId> <version>1.0.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>mymoduleproject</artifactId> </project>
<relativePath>.../parentDir/pom.xml</relativePath>
Maven Project Aggregation
There is another way to establish a relationship between a parent project and child projects: project aggregation. Instead of declaring a parent project in the child project, the parent project declares modules:<project> <modelVersion>4.0.0</modelVersion> <groupId>com.mygroupid</groupId> <artifactId>myprojectparent</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <modules> <module>mymoduleproject</module> </modules> </project>
parent's pom.xml:
<module>../myModuleDir/mymoduleproject</module>
REM: In this configuration, there is no inheritance between child projects and the parent project (only aggregation). Hence, child projects do not inherit of the parent's configuration. All projects of this aggregation inherit of the super pom.xml. They each have a life of their own.
No comments:
Post a Comment