1
~~ Licensed to the Apache Software Foundation (ASF) under one
2
~~ or more contributor license agreements. See the NOTICE file
3
~~ distributed with this work for additional information
4
~~ regarding copyright ownership. The ASF licenses this file
5
~~ to you under the Apache License, Version 2.0 (the
6
~~ "License"); you may not use this file except in compliance
7
~~ with the License. You may obtain a copy of the License at
9
~~ http://www.apache.org/licenses/LICENSE-2.0
11
~~ Unless required by applicable law or agreed to in writing,
12
~~ software distributed under the License is distributed on an
13
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
~~ KIND, either express or implied. See the License for the
15
~~ specific language governing permissions and limitations
28
This rule can enforce certain values about the Operating System and processor architecture.
29
The values and code used to determine if an OS is allowed are exactly the same as the OS Profile activation in Maven.
32
The following parameters are supported by this rule:
34
* message - an optional message to the user if the rule fails.
36
* {{{../apidocs/org/apache/maven/plugin/enforcer/RequireOS.html#arch}arch}} - the cpu architecture.
38
* {{{../apidocs/org/apache/maven/plugin/enforcer/RequireOS.html#family}family}} - the family of OS. Possible families are:
63
* {{{../apidocs/org/apache/maven/plugin/enforcer/RequireOS.html#name}name}} - the name of the OS.
65
* {{{../apidocs/org/apache/maven/plugin/enforcer/RequireOS.html#version}version}} - the version of the OS.
67
* {{{../apidocs/org/apache/maven/plugin/enforcer/RequireOS.html#display}display}} - flag to display the detected OS informatin.
72
Family is calculated based on testing against the name string retreived from the JDK. The name, arch and version values are retreived from the JDK using the following code:
75
public static final String OS_NAME = System.getProperty( "os.name" ).toLowerCase( Locale.US );
77
public static final String OS_ARCH = System.getProperty( "os.arch" ).toLowerCase( Locale.US );
79
public static final String OS_VERSION = System.getProperty( "os.version" ).toLowerCase( Locale.US );
82
Possible arch, name, and version values can be found here:
84
* {{{http://lopica.sourceforge.net/os.html}lopica.sourceforge.net}}
86
* {{{http://tolstoy.com/samizdat/sysprops.html}Sysprops}}
90
The various options are considered to be "and'd" together but any number can be specified.
91
(ie family = windows means windows, but family = windows and arch = x86 means only windows on x86 processors)
93
Any parameter may also be used in the negative by prepending a "!" in front of it. For example !dos means everything but dos. (who uses dos anyway?)
95
Since the various names, versions and architecture values cannot be listed exhaustively, there is an easy way to display the
96
information for the current system:
99
mvn enforcer:display-info
101
[enforcer:display-info]
103
JDK Version: 1.5.0_11 normalized as: 1.5.0
104
OS Info: Arch: x86 Family: windows Name: windows xp Version: 5.1
107
Sample Plugin Configuration:
115
<groupId>org.apache.maven.plugins</groupId>
116
<artifactId>maven-enforcer-plugin</artifactId>
117
<version>1.0</version>
127
<name>Windows XP</name>
128
<family>Windows</family>
130
<version>5.1.2600</version>
b'\\ No newline at end of file'