I currently have a pom with platform specific profiles (e.g. linux 32bit, windows 64 bit, etc...). Additionally, I have set it up to automatically choose the invoker's platform as a default.
Now, assume I am in a linux 32 machine: I also want to build for win64 by invoking mvn -Pwin64 pakage
but in doing so, both the linux32 and win64 profiles get activated. I have tried activating the local platform profile with activeProfiles
and using ativation
tags. The trouble is that -P does not disable all other profiles as explained in the documentation:
This option takes an argument that is a comma-delimited list of profile-ids to use. When this option is specified, no profiles other than those specified in the option argument will be activated.
Am I understanding this wrong? How would you handle this?
Note: I know I could run mvn -P-linux32,win64
but that is only valid on linux32 platforms, and any mistakes may result in a bloated build with duplicate classes.
Thanks!
Why don't you use the profile activation by plattform like this:
This statement from the profile docs:
Would lead me to try the solution below. Each developer defines his default platform as a property in his settings.xml file and overrides it on the cmdline if needed.
Developer's settings.xml
Project's pom.xml
Then,
mvn install
should activate the win32 profile because the default value for thebuild.platform
property is win32, whilemvn install -Dbuild.platform=linux32
will override the default property setting and use the Linux profile instead.