The One And Only Pom.xml

Have you guys seen the bottle of POM juice? It is filled with antioxidants and it tastes yum! similarly our pom.xml is filled with dependencies needed for our project .POM (Project Object Model) is an XML file that contains the information about the project and the configuration details used by Maven to build the project which means it contains the project dependencies , the source code location, the plugins etc. It is placed under root folder of project. When executing the code the maven reads the POM.xml and then executes the project.

Figure 1 : Simple Illustration

In the normal project development we add JAR files and libraries manually as required but in Maven-based development, these JAR files, libraries are added to the project using the pom.xml. In the pom context we call those JAR files, libraries as dependencies.

One cool fact : Initially the pom.xml was named as project.xml file But, since maven 2 it is renamed as pom.xml

Now that we know what pom.xml is lets dive deeper and checkout what its made of . To create a simple pom.xml file, we need the elements listed below in addition to these there are project specific elements we need to add as well which are also listed below.

Figure 2

Here is the example of my Pom.xml

Figure 3:A simple POM.xml file

Additionally we can add our project specific elements like the dependencies ,build plugins ,tags etc.

Figure 3.1

For example to run cucumber in our maven project we need to add the cucumber java dependencies if we want to test it we need the cucumber junit or testng dependency similarly to run maven successfully we need the maven surefire plugin .All this information goes into our pom.xml now lets understand what exactly are the dependencies and what they stand for in our pom.xml file ?

Dependencies are the libraries we use in your project application. If we are not using Maven, we have to manually download the jar files and add it to our project . But with maven, we can just updated pom.xml with the dependency we want and, Maven will do the downloading and adding it to our project

Figure 4:Dependancy Example

We can download all the dependencies we need in our project from Maven Repository at www.https://mvnrepository.com/


We now know what is pom.xml and its importance in maven project .In my next blog lets understand the different types of Pom.xml

Stay tuned!

19 views0 comments

Recent Posts

See All