Values for os.family in Maven profile activation condition
Asked Answered
N

4

35

Maven allows to activate certain build profiles based on the operating system family it runs on, for example:

<profile>
    <activation>
        <os><family>Windows</family></os>
    </activation>
</profile>

There is a number of question around this: what are allowed values for os.family then? Are they case sensitive? Does Linux come across as Unix? Or unix? And so on.

Where can I find information about allowed values – or, at least, where does Maven take these values from? Environment variables?

Nightfall answered 26/9, 2013 at 8:29 Comment(0)
S
30

The values are defined in the plexus-utils project, in Os.java. You can see in isOs that the match is case-insensitive, that the value is taken from System.getProperty( "os.name" ) and that you should specify unix to match a Linux platform.

Sidwohl answered 26/9, 2013 at 14:35 Comment(0)
M
37

A very useful Maven command for checking these OS properties on your machine:

mvn enforcer:display-info

Example output on a SunOS / Sparc host:

[INFO] Maven Version: 3.0.4
[INFO] JDK Version: 1.6.0_34 normalized as: 1.6.0-34
[INFO] OS Info: Arch: sparc Family: unix Name: sunos Version: 5.8

Example output on a Linux host:

[INFO] Maven Version: 3.0.4
[INFO] JDK Version: 1.7.0_85 normalized as: 1.7.0-85
[INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 2.6.32-504.23.4.el6.x86_64
Moramorabito answered 26/10, 2015 at 7:54 Comment(1)
This is also the suggested way by Apache, which links to this enforcer plugin page currently.Scrofula
S
30

The values are defined in the plexus-utils project, in Os.java. You can see in isOs that the match is case-insensitive, that the value is taken from System.getProperty( "os.name" ) and that you should specify unix to match a Linux platform.

Sidwohl answered 26/9, 2013 at 14:35 Comment(0)
F
28

OS family values:

dos
mac
netware
os/2
tandem
unix
windows
win9x
z/os
os/400
openvms

Other value you can get by run simple program:

public class SystemProperties {
    public static void main(String[] args) {
        System.out.println("Os name: " + System.getProperty("os.name"));
        System.out.println("Os arch: " + System.getProperty("os.arch"));
        System.out.println("Os version: " + System.getProperty("os.version"));
    }
}
Flap answered 23/10, 2014 at 13:36 Comment(1)
This system information is needed for the Spring Boot environment profile activation using OS information.Hentrich
H
9

it might worth asking from maven help:

mvn help:system | grep "os\."
Hamford answered 8/1, 2016 at 1:32 Comment(1)
This is what I needed to identify the variable ${os.detected.name} that I needed.Tranquilizer

© 2022 - 2024 — McMap. All rights reserved.