Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Project Object Model – What is POM?

pom

pom

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.

Super POM
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.
4.0.0
Maven Default Project

central
Maven Repository Switchboard
default
http://repo1.maven.org/maven2

false

central
Maven Plugin Repository
http://repo1.maven.org/maven2
default

false

never

target
target/classes
${artifactId}-${version}
target/test-classes
src/main/java
src/main/scripts
src/test/java

src/main/resources

src/test/resources

target/site
release-profile

performRelease

true
org.apache.maven.plugins
maven-source-plugin

attach-sources

jar

true
org.apache.maven.plugins
maven-javadoc-plugin

attach-javadocs

jar

true
org.apache.maven.plugins
maven-deploy-plugin

true

 

 

Minimal POM
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:


  4.0.0
  com.mycompany.app
  my-app
  1

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.
Project inheritance
Elements in the POM that are merged are the following:

  • dependencies
  • developers and contributors
  • plugin lists (including reports)
  • plugin executions with matching ids
  • plugin configuration
  • resources

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.

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x