top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Do you know the types of Project Object Models?

In my last blog post I already discussed what is pom.xml and how it is the backbone of our maven project . In this blog we will talk about the different types of Pom.xml .There are mainly three types of POMs

SuperPOM , Simple or minimal POM ,Effective POM . Now lets look at each in detail


SUPER POM.xml:

The Super POM is Maven's default POM. All our Maven project POMs extend the Super POM, which defines a set of defaults shared by all projects. The Super POM is a part of the Maven installation and need not be written by us . Depending on the Maven version it can be found in the maven-x.y.z-uber.jar or maven-model-builder-xy.z.jar file in ${M2_HOME}/lib. If you open this JAR file, you will find a file named pom-4.0.0.xml under the org.apache.maven.model package.

Tip
An analogy to how the Super POM is the parent for all Maven POM files, would be how java.lang.Object is the top of the class hierarchy for all Java classes like all classes extend the Object class of java same way does pom files extend super pom.

Here is the example of how the super pom.xml looks


Figure 1 :A Super POM

Minimal or Simple POM

The minimal POM is the simplest pom one can write . It is the pom you write in your maven project which includes dependencies or plugin configuration. If you are just writing a simple project that produces a JAR from you source code in src/main/java and you would want to run your JUnit tests in src/test/java, and want to build a project site using maven, we don't have to add the jar manually we would simply need a minimal pom.xml. This POM defines a groupId, artifactId, and version: the three required coordinates for every project.


The minimal POM configuration for any Maven project is extremely simple, which is as follows:


It requires:

  • 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

You need to add your project specific configuration on top of this minimal pom. For rest the configuration, if not specified, maven will use defaults from super pom file.


Effective POM

Effective POM is a combination of all the default settings from the super POM file and the configuration we define in our application POM. It is important to note that Maven uses default values for configuration elements when they are not overridden in the application pom.xml. We can see the effective POM from the command line along with the default values that Maven uses using the command below

mvn help:effective-pom

CONCLUSION

We by now know the different types of POM and when and how they can be used in our project .

If you have a minute, do read about the Pom.xml and why is it important in our maven project here.

Till then Keep Reading Keep Learning !



72 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page