What is POM
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects. Examples for this are the build directory, which is target; the source directory, which is src/main/java; the test source directory, which is src/main/test; and so on.
The POM was renamed from project.xml in Maven 1 to pom.xml in Maven 2. When executing a task or goal, Maven looks for the POM in the current directory. It reads the POM, gets the needed configuration information, then executes the goal.
Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists and such can also be specified.
The Super POM is Maven’s default POM. All POMs extend the Super POM unless explicitly set, meaning the configuration specified in the Super POM is inherited by the POMs you created for your projects. The snippet below is the Super POM for Maven 2.0.x.
The snippet below is the Super POM for Maven 2.0.x.
Maven Default Project
Maven Repository Switchboard
Maven Plugin Repository
The minimum requirement for a POM are the following:
- project root
- modelVersion – should be set to 4.0.0
- groupId – the id of the project’s group.
- artifactId – the id of the artifact (project)
- version – the version of the artifact under the specified group
Here’s an example:
A POM requires that its groupId, artifactId, and version be configured. These three values form the project’s fully qualified artifact name. This is in the form of ::. As for the example above, its fully qualified artifact name is “com.mycompany.app:my-app:1”.
Every Maven project has a packaging type. If it is not specified in the POM, then the default value “jar” would be used.
Elements in the POM that are merged are the following:
- developers and contributors
- plugin lists (including reports)
- plugin executions with matching ids
- plugin configuration
The Super POM is one example of project inheritance, however you can also introduce your own parent POMs by specifying the parent element in the POM, as demonstrated in the following examples.
- Kubrnetes: Example of StorageClass - February 27, 2023
- Checklist of Disaster Recovery Plan in Kubernetes (EKS) for GitLab - February 24, 2023
- Kubernetes: Pull an Image from a Private Registry using Yaml and Helm File - February 24, 2023