I'm just starting to learn about maven so this is probably a basic question, but so far I was unable to find a clear answer. In the pom.xml, we can define one or more profiles based on such criteria as environment settings and properties. Also, a well designed pom.xml will only contain profiles with mutually exclusive conditions. But what about the pom.xml contents that are outside of any profile? Do they constitute a default condition, if no profile match is found for activation? Or is this content processed unless a setting is overridden in the active profile?
-
I don't understand your question, could you provide a simple example? – Tunaki Oct 15 '15 at 07:20
-
@Tunaki, thanks for your reply, but I've answered this myself below. – Craig Davis Oct 16 '15 at 18:41
1 Answers
The wording to my question may have been a bit confusing, but I've figured it out. If Maven finds a profile in the pom.xml with a true condition, then the contents of that profile section take precedence over the corresponding contents of the rest of the pom.xml. However, any contents in the pom.xml that have no corresponding contents in the profile will be used regardless of which profile is selected. For example, if a pom.xml contains a profile for the dev environment and specifies as a dependency artifact Bar, version 1.0.1-SNAPSHOT, while outside of any profile the pom.xml specifies dependency Bar, version 1.0.0, then the latter will be used if the environment is not dev, while the former will be used for dev. If the same pom.xml specifies as a dependency artifact Foo, version 2.0.2 outside of any profile, while no profile lists this dependency, then every profile will inherit artifact Foo, version 2.0.2 since there was no conflict.

- 143
- 1
- 9