The question is related to Maven: Only activate profile A if profile B is not activated?, but it's more specific.
If I type one of the following:
mvn clean install -PspecificProfile
mvn clean install -Dsmth -PspecificProfile
mvn clean install -Dsmth -PspecificProfile,anotherProfile
then I want to activate the specificProfile
profile. (+the additional specified profiles)
If I type anything else like:
mvn install
mvn clean install
mvn clean install -Dsmth
mvn clean install -Dsmth -PanotherProfile
mvn clean install -Dsmth -PdefaultProfile
mvn clean install -Dsmth -PdefaultProfile,anotherProfile
then I want to activate the defaultProfile
(+the additional specified profiles).
Idea:
if ( specific profile P is used via command line ) {
activate P;
} else {
activate the default profile;
}
activate other specified profiles;
Examples:
mvn ... // default
mvn ... -PspecificProfile // specificProfile (no default!)
mvn ... -Px // default + x
mvn ... -Px,y // default + x + y
mvn ... -Px,specificProfile // x + specificProfile (no default!)
mvn ... -Px,specificProfile,y // x + specificProfile + y (no default!)
I tried to do something like this (in pom.xml):
<profile>
<id>defaultProfile</id>
<activation>
<property>!x</property>
</activation>
...
</profile>
<profile>
<id>specificProfile</id>
<properties>
<x>true</x>
</properties>
...
</profile>
but it doesn't work.