In MAVEN based applications, it is possible to inherit configurations from one pom file to another pom file in order to avoid configurations redundancy. To declare parent pom , we have to use “pom” as value to <packaging> tag in parent pom file.
<project ..... > <!-- Project Description --> <modelVersion>4.0.0</modelVersion> <groupid>com.ashok.banking</groupid> <artifactid>icici.accounts</artifactid> <version>1.0</version> <name>Account Application</name> <packaging>pom</packaging> ----- </project>
If we want to inherit parent pom configuration details into a particular child pom then we have to configure parent pom in child pom.
<project ..... > <parent> <groupid>com.ashok.banking</groupid> <artifactid>icici.accounts</artifactid> <version>1.0</version> </parent> ----- </project>
1. In JAVA, java.lang.Object class is common and default super class for every java class in order to provide 11 common and default methods to each and every java class, similarly , there is a common and default super pom file is existed in maven in order to provide all common configurations and settings to the child pom file. In general, parent pom contains the following configurations
- Common data – Developers’ names, SCM address, distribution management etc.
- Constants – Such as version numbers
- Common dependencies – Common to all child. It has same effect as writing them several times in individual pom files.
- Properties – For example plugins, declarations, executions and IDs.
2. By default, Maven looks for the parent POM first at project’s root, then the local repository, and lastly in the remote repository. If parent POM file is not located in any other place, then you can use code tag. This relative path shall be relative to project root.
<parent> <groupid>com.ashok.banking</groupid> <artifactid>icici.accounts</artifactid> <version>1.0</version> <relativePath>../baseapp/pom.xml</relativePath> </parent>
If we want to get super pom from MAVEN then use the following command on command prompt from the project root location which contains project specific pom file.
Where effective-pom is super pom configurations and project configurations.