I have a maven module with 2 profile profile-a and profile-b
profile-a can be used independent but profile-b should be run with profile-a
mvn install -P profile-a // valid
mvn install -P profile-a,profile-b // valid
mvn install -P profile-b // INVALID
is there anyway to make sure that user cannot install the module with only profile-b?
or active the profile-a automatically if profile-b used alone?
No, there is no way to trigger a profile from another one (not supported, see Brett’s answer to a related question) nor to strictly forbid the use of a given profile.
The best thing you can do is to use property activation and a common property to activate both profiles:
And passing the property when invoking mvn would trigger both of them:
That’s not ideal, but currently, that’s the best you can get.
Related questions