Can I make one maven profile activate another?
Asked Answered
P

1

83

I have 2 maven2 profiles, selenium and jspc. Now for "selenium" id'd like to have an implicit activation of "jspc", so that I don't have to write mvn -Pselenium,jspc from the command line. Is this possible ?

Photocompose answered 3/6, 2009 at 6:51 Comment(0)
E
103

You can't "chain" profile activations (maven reference) but you can activate them both through the same property:

<activation>
  <property>
    <name>profile.selenium</name>
  </property>
</activation>

And the run mvn -Dprofile.selenium

Embower answered 3/6, 2009 at 7:17 Comment(4)
https://mcmap.net/q/244268/-why-can-39-t-i-activate-a-maven2-profile-from-another-profile has some more detail on why you can't chain.Amargo
Also, you can define activation based on properties NOT being there - this allows you to create mutually exclusive profiles (unless you force-activate both). E.g. <profile> <id>test-default</id> <activation> <property> <name>!profile.externalAndContractTests</name> </property> </activation>...Macario
For my case, I have profile1 extends profile2 extends profile3, so the above would not work because activation only can use one property. Instead I just use maven-enforcer-plugin with requireProperty and paste the mvn install -Dprofile1,profile2,profile3 inside the requireProperty->message. So everytime I just do mvn install profile3, get the warning and copy the output message and run again.Odelle
@Amargo always someone trying to justify WHY. I can see 100 ways to implement this. Just look for profiles that match, unify them.Tacet

© 2022 - 2024 — McMap. All rights reserved.