Minimum Requirements
The following are the minimum requirements for a POM:
-
artifactId: It is the id of the artefact (project). This is the project's official name. The artifactId identifies the artifact's position in the repository along with the groupId. For example, Maven-articles in all article-related projects.
-
groupId: It is the id of the project’s group. This is typically unique inside a company or a project. For example, all articles-related projects are included in the com.Coding Ninjas Studio.library codingninjas group.
-
project: It is the root of the project. You need to specify the primary schema.
-
modelVersion: It should be set to 4.0.0
-
Version: It refers to the version of the object under the specified group. For example:
com.Coding Ninjas Studio.library:maven-articles:1.0
com.Coding Ninjas Studio.library:maven-articles:2.0
Example
Here is an example of the POM:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.CodingNinjas.app</groupId>
<artifactId>Coding Ninjas Studio-app</artifactId>
<version>1.0</version>
</project>
Every project should have its own POM file, it should be mentioned. The project element and the three required fields groupId, artifactId, and version are required in every POM file.
GroupId:ArtifactId:Version is the repository's nomenclature for projects.
Additional Elements
In addition to the minimum requirements, you can also add some additional elements to the pom.xml file. These elements are as follows:
-
Dependency: It outlines the project's dependencies.
-
Name: The maven project's name is defined by name.
-
Packaging: It specifies the type of packaging, such as jar, war, etc.
-
Scope: This Maven project's scope is defined by scope.
-
URL: It specifies the project's URL.
Example
Here is an example of the POM file with additional elements:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.CodingNinjas.app</groupId>
<artifactId>Coding Ninjas Studio-app</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>Coding Ninjas Maven Articles</name>
<url>https://www.codingninjas.com</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Frequently Asked Questions
What is Super POM?
Maven's default POM is the Super POM. Unless explicitly stated, all POMs extend the Super POM, which means that the POMs you made for your projects inherit the configuration defined in the Super POM.
What is the POM XML model?
It is an XML file that is located in the project's base directory as pom.xml. The POM includes details about the project and different configuration settings that Maven uses to build the projects.
POM is which type of framework?
POM is a fusion of data-driven, modular, and hybrid frameworks. It's a method for logically arranging the scripts to make it simple for the QA to maintain the code without difficulty and aids in avoiding redundant or duplicate code.
How to create a POM file?
Selecting a project, including the Group Id, Artifact Id, Version, Packaging type, and file name, into the appropriate fields, is all required to create a new Maven POM. You can add dependencies by clicking the Next button to create a POM file.
Conclusion
We discussed the Maven Project Object Model. We discussed the uses of POM in Maven and the config details of the POM. Further, we discussed the minimum requirements of POm along with an example. We also covered some additional elements of the pom file.
We hope this blog has helped you. We recommend you visit our articles on different topics of Maven, such as
🔥 What do you mean by Maven?
🔥 Maven Configuration Properties.
🔥 Introduction to Maven Commands.
If you liked our article, do upvote our article and help other ninjas grow. You can refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, System Design, and many more!
Head over to our practice platform Coding Ninjas Studio to practice top problems, attempt mock tests, read interview experiences and interview bundles, follow guided paths for placement preparations, and much more!!
Happy Reading!!