Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the order of overwrite Maven properties in pom.xml and settings.xml?

Tags:

java

maven

today I observed that the maven proprties defined in settings.xml overwrite the one in pom.xml.

Because it is only a observation, I am not sure if this is totally correct. So I am looked for the reference or some article but I find no concrete statement about the behaviour of overwriting properties defined with the same name in settings.xml and pom.xml.

Maybe someone can provide a link to the reference part (that I may overlooked) or the a reliable article/blog?

like image 882
Ralph Avatar asked Apr 30 '12 09:04

Ralph


2 Answers

Based on the documentation in my opinion it is clear which one has precedence over the other (excerpt of the docs):

If a profile is active from settings, its values will override any equivalently ID'd profiles in a POM or profiles.xml file.

The profiles.xml does not exist anymore in Maven 3 only in Maven 2.2.1 it is supported but shouldn't be used.

like image 144
khmarbaise Avatar answered Sep 22 '22 11:09

khmarbaise


I think properties with equal names are overridden in next sequence (from highest to lowest context):

  • Global
  • Profile descriptor
  • Per project
  • Per user

http://maven.apache.org/guides/introduction/introduction-to-profiles.html

Hence, pom.xml properties (per project) are overridden by settings.xml (per user) properties with equal names.

like image 38
Alexander Volkov Avatar answered Sep 24 '22 11:09

Alexander Volkov