I have a project that has several profiles. How do you make one of the profiles activate only if no other profiles are active?
Activate Maven profile if no other profile activated
Asked Answered
As explained in Introduction to Build Profiles:
Profiles can also be active by default using a configuration like the following:
<profiles> <profile> <id>profile-1</id> <activation> <activeByDefault>true</activeByDefault> </activation> ... </profile> </profiles>
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.
Oh, thanks for clarifying! I thought activeByDefault meant that it will always be active. –
Westbrook
"another profile in the same pom is activated" this is an important point, if you use multi-module, the parent profiles should appear in the child pom event if empty. Else the "activateByDefault" will always be activated, even for other profiles. –
Cornered
© 2022 - 2024 — McMap. All rights reserved.