I want Maven to skip building all sub-modules if the user neglects to specify a build profile. https://stackoverflow.com/a/8305931/14731 explains how to include a module if a profile is selected, but not how to exclude it.
I understand I can copy the <modules>
to build into all non-default profiles but the list of modules is huge and I have over 9 different profiles, making this a maintenance nightmare.
Is there a way to exclude/skip sub-modules if a profile is activated? Alternatively, is there a way to store the module list into a property and re-use it from multiple profiles without having to repeat the entire list each time?
Question 1
Only way I can see is to only define modules in profiles for which they should be active, perhaps including a 'special' profile that is
activeByDefault
if you want them active by default...But that suffers from the issue that if somebody does
Then the active by default profiles will still be active (i.e. the modules will still be there)
Note:
-Pprofile
activates the profile namedprofile
and deactivates all active by default profiles.-P-profile
deactivates the (presumably) active by default profile namedprofile
.-P+profile
activates the profile namesprofile
without affecting the active profiles.Question 2
Not that I am aware of. Property substitution is, in general, not available while Maven is computing the build plan.