mavenmulti-modulemaven-package

What tags are really required or recommended when using packaging type pom in Maven?


Once you set packaging equal to pom, do you need the groupID, artifactId and version tags and if so, what purpose do they serve? Are there any tags you should use (after all groupID is clearly intended for java so I wouldn't be surprised if there are other language or artifact type specific tags that should be used). Samples:

Simple parent pom:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.company</groupId>
    <artifactId>project_name</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <modules>
        <module>hosts</module>
    </modules>

</project>

Simple child pom:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.company</groupId>
    <artifactId>hosts</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    
</project>

Then sub children are various projects of many types, java, C++, angular, python, more poms.


Solution

  • You need all those tags.

    The POMs are deployed along with the JARs, WARs etc. with their respective Maven coordinates (GroupId, ArtifactId, Version). They are resolved if anybody uses e.g. a dependency with your parent.