Maven profile dependency with another profile

608 views Asked by At

When I do mvn clean install it will run a default active maven profile and the Master POM.

When I do mvn clean install -P anotherProfile it is executing default active maven profile + anotherProfile.

But if default profile fails i don't want the another profile to run.how do i do it?

eg:

mvn clean install - default active profile
mvn clean install -P anotherProfile - default+anotherProfile

the second line works fine but I don't want it to run anotherprofile if default profile fails.

1

There are 1 answers

0
wemu On

If you want one profile to be activated but another one to be disabled you can use a ! to disable it:

mvn install -P profile1

will activate profile1

mvn install -P profile2,!profile1

will activate profile2 but de-activate profile1

You may be able to use the activation of the profiles to turn them on or off depending on some properties and to not rely on manual activation.

see: http://maven.apache.org/guides/introduction/introduction-to-profiles.html