Order does matter
Ever used profiles in maven? Great stuff. Ever tried to trigger multiple profiles? Great in theory, but unfortunately in this case maven is not delivering what one would expect - especially when you have the the same properties in multiple profiles and you want the values of the 'last' profile activated to be the effective ones. This is exactly how settings.xml works. If a profile in settings.xml is activated and it defines a property which was already set by another profile it overrides its value. Not so with multiple profiles defined in pom.xml. Say we have to two profiles default and override defined as follows in pom.xml:
<profile> <id>default</id> <properties> <test>DEFAULT</test> </properties> </profile> <profile> <id>override</id> <properties> <test>OVERRIDE</test> </properties> </profile>
Running the build via:
> mvn install -P default,override
one would expect that the value for property test is 'OVERRIDE', but it is not :( It turns out there is a bug in maven which causes the order of the profile activation to be undetermined. The good news is that this particular problem is solved - in version 2.1-alpha! This means until maven 2.1 is available watch out when trying to use profile overriding. It can save you a few hours of tearing at your hair trying to figure out why the build is not behaving the way you want it to behave.