Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why modelVersion of pom.xml is necessary and always set to 4.0.0?

Tags:

maven

I have noticed that Maven's <modelVersion></modelVersion> of pom.xml is always set to 4.0.0.

Can you please help me understand what is the importance of this tag and why it should be set to 4.0.0?

like image 696
mahesh Avatar asked Nov 03 '13 23:11

mahesh


People also ask

What happens if you don't specify version in POM xml?

of your question: If you don't specify a version there are various different outcomes: a) you will get an error... b) if you have defined the version in the dependency management of the project's parent's pom, then that version is taken. The parent of the project doesn't have to be an enclosing superproject.

What is the importance of POM XML file?

What is a POM? A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.

Is POM xml necessary?

pom. xml is required for building project using Maven. You might import jars manually in eclipse but for building the project in some other build system which supports Maven, you would need pom.

What are the required elements of the POM xml?

defines packaging type such as jar, war etc. defines name of the maven project. defines url of the project. defines dependencies for this project.


2 Answers

It is always set to 4.0.0 in Maven 2 and 3, because, at present, there is no other model.

Notice that modelVersion contains 4.0.0. That is currently the only supported POM version, and is always required. [source]

But it wouldn't necessarily need to always be set to 4.0.0 if there was another version of the model. A POM has to comply with a model. Let's say Maven 4 comes up with model 4.1. If you write your pom to comply with 4.1, it wouldn't be compatible with Maven 3 and model 4.0.0.

It's defined as a mandatory, possibly to enforce a specific XML model in case new models are defined.

like image 152
Boj Avatar answered Oct 05 '22 04:10

Boj


model version is the version of project descriptor your POM conforms to. It needs to be included and is set. The value 4.0.0 just indicated that it is compatible Maven 3.

like image 44
Toumi Avatar answered Oct 05 '22 04:10

Toumi