Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are conflicting properties resolved if multiple profiles are activated

Tags:

java

maven

build

Maven profiles documentation does not mention this, and it is probably a sign of bad build process design, but are there rules for resolving conflicting properties if multiple profiles are active and they all define the same property?

Im quite sure that local declaration (in the pom.xml) would override the declaration in the settings.xml, not so sure for colocal profiles

  • is the declaration order inside the file important?
  • is there a defined activation order that may be important?
  • is the order important, if activated manually over CLI (-Pprofile1,profile2)?

Thank you

like image 918
kostja Avatar asked Sep 18 '12 12:09

kostja


1 Answers

There is no resolving conflicts happening - only overriding. Afaik the order is settings, pom, and then command line. For multiple profiles in a pom and settings file the order in the file matters as well and beyond that things are different depending on Maven version.

I would strongly suggest to reduce your usage of profiles so that you do NOT have to worry about these complexities and certainly get the help plugin installed.

Also you can see the effective pom within Eclipse in the M2Eclipse plugin in the POM editor. That should help you in the mean time.

And answer to your questions:

Yes

Yes

Yes

All orders matter and can result in, lets just say "surprising" results sometimes.

like image 66
Manfred Moser Avatar answered Sep 20 '22 03:09

Manfred Moser