I have two profiles defined in my pom.xml:
<profiles>
<profile>
<id>nobrand</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<brand>nobrand</brand>
</properties>
</profile>
<profile>
<id>mybrand</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<brand>mybrand</brand>
</properties>
</profile>
</profiles>
The <build>
section simply uses the property that is set by each profile.
Both profiles are set as active by default. However, only the last one is executed by mvn package
. Why? I expected the build to be executed twice.
Profiles that are active by default are automatically deactivated when another profile is activated. Since both of your profiles are activated by default, the second one turns active and deactivates the first one.
Quoting from the Maven docs about the activeByDefault
property (emphasis mine):
This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With