Maven pom.xml file


POM is an abbreviation for Project Object Model. The pom.xml document contains data of task and design data for the maven to build the project , for example, conditions, manufacture registry, source catalog, test source index, plugin, objectives etc.

Maven peruses the pom.xml document, at that point executes the goal.

Before maven 2, it was named as project.xml document. Be that as it may, since maven 2 (likewise in maven 3), it is renamed as pom.xml.


Elements of maven pom.xml file

For making the straightforward pom.xml record, you need following elements:

ElementDescription
project It is the root component of pom.xml file.
modelVersion It is the sub component of undertaking. It indicates the modelVersion. It ought to be set to 4.0.0.
groupId It is the sub component of task. It indicates the id for the undertaking group.
artifactIdIt is the sub component of task. It indicates the id for the antique (project ). An antique is something that is either delivered or utilized by a task. Instances of antiquities delivered by Maven for a task include: JARs, source and binary distributions, and WARs.
versionIt is the sub component of task. It determines the variant of the relic under given group.
File: pom.xml
  1. <project xmlns="http://maven.apache.org/POM/4.0.0"   
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   
  4. http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  5.   
  6.   <modelVersion>4.0.0</modelVersion>  
  7.   <groupId>com.javacodegeeks.application1</groupId>  
  8.   <artifactId>my-app</artifactId>  
  9.   <version>1</version>  
  10.   
  11. </project>  

Maven pom.xml record with extra elements

Here, we are going to include different components in pom.xml record such as:

ElementDescription
packaging defines bundling type, for example, jar , war etc.
name defines name of the maven project.
url defines url of the project.
dependenciesdefines dependencies for this project.
dependencydefines a dependency. It is utilized inside dependencies.
scopedefines scope for this maven project . It very well may be assemble, if, runtime, test and system.
File: pom.xml
  1. <project xmlns="http://maven.apache.org/POM/4.0.0"   
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   
  4. http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  5.   
  6.   <modelVersion>4.0.0</modelVersion>  
  7.   
  8.   <groupId>com.javacodegeeks.application1</groupId>  
  9.   <artifactId>my-application1</artifactId>  
  10.   <version>1.0</version>  
  11.   <packaging>jar</packaging>  
  12.   
  13.   <name>Maven Quick Start Archetype</name>  
  14.   <url>http://maven.apache.org</url>  
  15.   
  16.   <dependencies>  
  17.     <dependency>  
  18.       <groupId>junit</groupId>  
  19.       <artifactId>junit</artifactId>  
  20.       <version>4.8.2</version>  
  21.       <scope>test</scope>  
  22.     </dependency>  
  23.   </dependencies>  
  24.   
  25. </project>  





javacodegeeks is optimized for learning.© javacodegeeks .
All Right Reserved and you agree to have read and accepted our term and condition