What is a Maven POM(pom.xml) file? - Maven Tutorial



The pom.xml file is the core of a project’s configuration in Maven. It is a single configuration file that contains the majority of information required to build a project in just the way you want.

pom.xml file describes the software project being built, its dependencies on other external modules and components, the build order, directories, and required plug-ins

The POM is huge and can be daunting in its complexity.


Maven projects are configured using a Project Object Model, which is stored in a pom.xml-file. Here’s a minimal example:

<project>  <!-- model version is always 4.0.0 for Maven 2.x POMs -->  <modelVersion>4.0.0</modelVersion>   <!-- project coordinates, i.e. a group of values which       uniquely identify this project -->  <groupId>com.mycompany.app</groupId>  <artifactId>my-app</artifactId>  <version>1.0</version>  <!-- library dependencies -->    <dependencies>    <dependency>      <!-- coordinates of the required library -->            <groupId>junit</groupId>      <artifactId>junit</artifactId>      <version>3.8.1</version>          <!-- this dependency is only used for running and compiling tests -->           <scope>test</scope>        </dependency>  </dependencies></project>

Minimal POM

The minimum requirement for a POM is the following:

1. project root2. modelVersion - should be set to 4.0.03. groupId - the id of the project's group.4. artifactId - the id of the artifact (project)5. version - the version of the artifact under the specified group

Here’s an example:

<project>  <modelVersion>4.0.0</modelVersion>  <groupId>com.mycompany.app</groupId>  <artifactId>my-app</artifactId>  <version>1</version></project>

Elements in the POM that are merged are the following:

 1. dependencies 2. developers and contributors 3. plugin lists (including reports) 4. plugin executions with matching ids 5. plugin configuration 6. resources