Maven配置文件激活条件中os.family的值

时间:2021-11-16 11:25:24

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

Maven允许基于其运行的操作系统系列激活某些构建配置文件,例如:

<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.

围绕这个问题有很多问题:os.family的允许值是什么?他们是否区分大小写? Linux是否与Unix相遇?还是unix?等等。

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

我在哪里可以找到有关允许值的信息 - 或者至少Maven从哪里获取这些值?环境变量?

4 个解决方案

#1


20  

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.

这些值在Os.java中的plexus-utils项目中定义。您可以在isOs中看到匹配不区分大小写,该值取自System.getProperty(“os.name”),并且您应指定unix以匹配Linux平台。

#2


12  

OS family values:

OS系列值:

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"));
    }
}

#3


10  

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

一个非常有用的Maven命令,用于检查计算机上的这些OS属性:

mvn enforcer:display-info

Example output on a SunOS / Sparc host:

SunOS / Sparc主机上的示例输出:

[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:

Linux主机上的输出示例:

[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

#4


2  

it might worth asking from maven help:

它可能值得从maven帮助询问:

mvn help:system | grep "os\."

#1


20  

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.

这些值在Os.java中的plexus-utils项目中定义。您可以在isOs中看到匹配不区分大小写,该值取自System.getProperty(“os.name”),并且您应指定unix以匹配Linux平台。

#2


12  

OS family values:

OS系列值:

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"));
    }
}

#3


10  

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

一个非常有用的Maven命令,用于检查计算机上的这些OS属性:

mvn enforcer:display-info

Example output on a SunOS / Sparc host:

SunOS / Sparc主机上的示例输出:

[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:

Linux主机上的输出示例:

[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

#4


2  

it might worth asking from maven help:

它可能值得从maven帮助询问:

mvn help:system | grep "os\."