Require OS Version

This rule can enforce certain values about the Operating System and processor architecture. The values and code used to determine if an OS is allowed are exactly the same as the OS Profile activation in Maven.

The following parameters are supported by this rule:

  • message - an optional message to the user if the rule fails.
  • arch - the cpu architecture.
  • family - the family of OS. Possible families are:
    • dos
    • mac
    • netware
    • os/2
    • tandem
    • unix
    • windows
    • win9x
    • z/os
    • os/400
  • name - the name of the OS.
  • version - the version of the OS.
  • display - flag to display the detected OS informatin.

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:

    public static final String OS_NAME = System.getProperty( "" ).toLowerCase( Locale.US );

    public static final String OS_ARCH = System.getProperty( "os.arch" ).toLowerCase( Locale.US );

    public static final String OS_VERSION = System.getProperty( "os.version" ).toLowerCase( Locale.US );

Possible arch, name, and version values can be found here:

The various options are considered to be "and'd" together but any number can be specified. (ie family = windows means windows, but family = windows and arch = x86 means only windows on x86 processors)

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?)

Since the various names, versions and architecture values cannot be listed exhaustively, there is an easy way to display the information for the current system:

mvn enforcer:display-info
Maven Version: 2.0.6
JDK Version: 1.5.0_11 normalized as: 1.5.0
OS Info: Arch: x86 Family: windows Name: windows xp Version: 5.1

Sample Plugin Configuration:

                  <name>Windows XP</name>