Given two profiles A and B, is it possible to specify something within profile A definition that would enable or disable profile B?
This is not possible to activate / deactivate a profile from another profile. Maven needs to know the list of active profiles before building the model.
There are a couple of work-arounds depending on your use-case:
activeByDefault
: it will be automatically deactivated
when another profile is activated.Use a custom property so that one profile is activated by the presence of the property and the other profile is deactivated by the presence of the property. Sample configuration would look like:
<profile>
<id>profileA</id>
<activation>
<property>
<name>somename</name>
</property>
</activation>
</profile>
<profile>
<id>profileB</id>
<activation>
<property>
<name>!somename</name>
</property>
</activation>
</profile>
Thus, if you invoke Maven with -Dsomename
, profileA
will be activated; otherwise profileB
will be activated.
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