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

Family is calculated based on testing against the name string retrieved from the JDK. The name, arch and version values are retrieved 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 );

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 !windows means everything but windows.

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

Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
Maven home: /usr/local/Cellar/maven/3.8.7/libexec
Java version: 1.8.0_352, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@8/1.8.0+352/libexec/openjdk.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "12.6.1", arch: "x86_64", family: "mac"

Sample Plugin Configuration:

                  <name>Windows XP</name>