Home > front end >  Parent POM vs Super POM - are they same?
Parent POM vs Super POM - are they same?

Time:11-05

I want to understand if Parent POM and Super POM are same or are there still differences.

Take below maven poms, I declare a parent pom as below:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.demo</groupId>
    <artifactId>deps</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <dependencyManagement>
            <dependencies>    
                   <!-- not relevant for this question -->
            </dependencies>
        </dependencyManagement>
    <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>5.3.12</version>
            </dependency>
    </dependencies>
</project>

Now I declare a child pom as below:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.demo</groupId>
    <artifactId>deps2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <parent>
       <groupId>com.demo</groupId>
       <artifactId>deps</artifactId>
       <version>0.0.1-SNAPSHOT</version>
    </parent>
    <dependencies>
                           <!-- not relevant for this question -->

    </dependencies>
</project>

Now deps is the parent pom for deps2. I am not sure if I can also call deps as super pom for deps2.

Which of the below inheritance hierarchy is correct

  1. dep2 --> deps end (NO Maven provided super pom)
  2. dep2 --> deps --> Maven provided super pom end

CodePudding user response:

Option 2, because all models implicitly inherit from the Super POM.

deps is a parent for deps, but not the Super POM. This is according to the definitions on the website.

What is more ... if you inspect the effective POM, you will see that it will always inherit from the Super POM on the MVN website.

  • Related