Let’s see, the example of Maven POM.xml file. The configuration of a Maven project is done via a Project Object Model (POM).
The pom.xml file contains information of project and configuration information for the maven to build the project. This includes the directories where the source code, test source etc. is located in, what external dependencies (JAR files) your projects has etc.
The POM file describes what to build, but most often not how to build it. How to build it is up to the Maven build phases and goals.
Each project has a POM file. The POM file is named pom.xml and should be located in the root directory of your project.
A project divided into subprojects will typically have one POM file for the parent project, and one POM file for each subproject. This structure allows both the total project to be built in one step, or any of the subprojects to be built separately.
Elements of Maven pom.XML File
Maven pom.xml file can contain the following Elements –
Project – Project is the root element of pom.xml file.
modelVersion – This element sets what version of the POM model you are using. Use the one matching the Maven version you are using. Version 4.0.0 matches Maven version 2 and 3.
groupId – The groupId element is a unique ID for an organization or a project. This is normally a reverse domain name. For the generation, the groupId also defines the package of the main class. For instance, for my Selenium Project, I may choose the group ID com.SeleniumBix .
artifactId – The artifactId element contains the name of the project you are building. It defines the unique name of the project. If you generate a new project via Maven this is also used as the root folder for the project.
In the case of my project, the artifact ID would be automation-framework. The artifact IDis used as the name for a subdirectory under the group ID directory in the Maven repository.
version – The versionId element contains the version number of the project. If your project has been released in different versions, for instance, an open source API, then it is useful to version the builds. That way users of your project can refer to a specific version of your project.
A project’s groupId:artifactId:version (also known as GAV) make that project unique.
The full Maven coordinates are often written in the following format: groupId:artifactId:packaging:version.
By default, this is the only configuration file required for the build process.
Let’s see the example of maven pom.xml file –
Products from Amazon.in
Price: Check on Amazon
Price: INR 29,950.00
Price: INR 17,999.00
<?xml version=”1.0″ encoding=”UTF-8″?>
<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”