Skip to content

Parent POM

Michael Hillman edited this page Aug 16, 2021 · 4 revisions

A parent pom.xml file (or super POM) in Maven is used to structure a project in order to avoid redundancies and duplicate configurations by using inheritance between different pom.xml files.

A parent pom.xml file for all Java-based World Avatar projects has been created and uploaded to the package repository. It specifies which versions of common libraries should be used, and includes centralised definitions of plugins that child projects can opt to use. Once used, if a dependency or plugin is declared within the child project, any fields not present in the child will be inherited from the parent. This means that a child project can declare a dependency without a <version> field; the version will then be pulled from the parent project, ensuring that all Java projects use a compatible version. For an example of a child project inheriting from the parent, see the example Java agent.

The source copy of the parent pom.xml file can be found within the ./Agents/utils/parent-pom directory. Java projects that wish to inherit from it can simply add the following XML snippet to their own project's pom.xml file.

<parent>
    <groupId>uk.ac.cam.cares.jps</groupId>
    <artifactId>jps-parent-pom</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

Note: it looks like, in some cases, Eclipse can report warnings when using a Parent POM. The Parent POM has its own version tag, and so should your project, but they are not related and do not inherit from each other (despite Eclipse's warning that they do).