I want to set some properties based on the OS type, so I have the following in my pom.xml
:
<project ...>
<profiles>
<profile>
<id>KenMacbook</id>
<activation>
<os><family>mac</family></os>
</activation>
<properties>
<test.r.version>3.3</test.r.version>
</properties>
</profile>
<profile>
<id>LinuxBox</id>
<activation>
<os><family>unix</family></os>
</activation>
<properties>
<test.r.version>3.2</test.r.version>
</properties>
</profile>
</profiles>
...
</project>
On my Mac, I check what profiles are active:
% mvn help:active-profiles | grep -v INFO
Active Profiles for Project 'com.foo:bar:jar:2.0.3-SNAPSHOT':
The following profiles are active:
- nexus (source: external)
- KenMacbook (source: com.foo:bar:2.0.3-SNAPSHOT)
- LinuxBox (source: com.foo:bar:2.0.3-SNAPSHOT)
So it looks like the <activation>
for the LinuxBox
profile isn't successfully excluding that profile on Mac. Am I misunderstanding something about how profile selection works?
Maven details:
% mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.5", arch: "x86_64", family: "mac"
The proper solution is to specify name.
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
A full cross-platform solution is:
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<modules>
<module>tests/org.eclipse.swt.tests.cocoa</module>
</modules>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
<modules>
<module>tests/org.eclipse.swt.tests.gtk</module>
</modules>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<modules>
<module>tests/org.eclipse.swt.tests.win32</module>
</modules>
</profile>
Source: http://maven.40175.n5.nabble.com/Profile-activation-for-mac-and-linux-td3263043.html