Class Os

java.lang.Object
org.apache.maven.shared.utils.Os

public class Os extends Object

Condition that tests the OS type.

This class got copied over from Apache ANT. Even the version from plexus-utils was only an ANT fork! The last time it got copied was on 2011-08-12

When merging changes please take care of the special OS_FAMILY handling in this version of Os.java!

  • Field Details

    • OS_NAME

      public static final String OS_NAME
      The OS Name.
    • OS_ARCH

      public static final String OS_ARCH
      The OA architecture.
    • OS_VERSION

      public static final String OS_VERSION
      The OS version.
    • PATH_SEP

      public static final String PATH_SEP
      The path separator.
    • LINE_SEP

      public static final String LINE_SEP
      system line separator , e.g. "\n" on unixoid systems and "\r\n" on Windows
    • OS_FAMILY

      public static final String OS_FAMILY
      OS Family
    • VALID_FAMILIES

      private static final Set<String> VALID_FAMILIES
    • family

      private String family
      OS family to look for
    • FAMILY_WINDOWS

      public static final String FAMILY_WINDOWS
      OS family that can be tested for. "windows"
      See Also:
    • FAMILY_WIN9X

      public static final String FAMILY_WIN9X
      OS family that can be tested for. "win9x"
      See Also:
    • FAMILY_NT

      public static final String FAMILY_NT
      OS family that can be tested for. "winnt"
      See Also:
    • FAMILY_OS2

      public static final String FAMILY_OS2
      OS family that can be tested for. "os/2"
      See Also:
    • FAMILY_NETWARE

      public static final String FAMILY_NETWARE
      OS family that can be tested for. "netware"
      See Also:
    • FAMILY_DOS

      public static final String FAMILY_DOS
      OS family that can be tested for. "dos"
      See Also:
    • FAMILY_MAC

      public static final String FAMILY_MAC
      OS family that can be tested for. "mac"
      See Also:
    • FAMILY_TANDEM

      public static final String FAMILY_TANDEM
      OS family that can be tested for. "tandem"
      See Also:
    • FAMILY_UNIX

      public static final String FAMILY_UNIX
      OS family that can be tested for. "unix"
      See Also:
    • FAMILY_OPENVMS

      public static final String FAMILY_OPENVMS
      OS family that can be tested for. "openvms"
      See Also:
    • FAMILY_ZOS

      public static final String FAMILY_ZOS
      OS family that can be tested for. "z/os"
      See Also:
    • FAMILY_OS400

      public static final String FAMILY_OS400
      OS family that can be tested for. "os/400"
      See Also:
    • DARWIN

      private static final String DARWIN
      OpenJDK is reported to call MacOS X "Darwin"
      See Also:
  • Constructor Details

    • Os

      public Os()
      Default constructor
    • Os

      public Os(String family)
      Constructor that sets the family attribute
      Parameters:
      family - a String value
  • Method Details

    • getValidFamilies

      public static Set<String> getValidFamilies()
      The set of valid families. This methods initializes the set until VALID_FAMILIES constant is set.
      Returns:
      The set of families.
    • setFamily

      private void setFamily(String f)
      Sets the desired OS family type
      Parameters:
      f - The OS family type desired
      Possible values:
      • dos
      • mac
      • netware
      • os/2
      • tandem
      • unix
      • windows
      • win9x
      • z/os
      • os/400
    • eval

      boolean eval()
      Determines if the OS on which Ant is executing matches the type of that set in setFamily.
      Returns:
      true if the os matches.
      See Also:
    • isFamily

      public static boolean isFamily(String family)
      Determines if the OS on which Ant is executing matches the given OS family.
      Parameters:
      family - the family to check for
      Returns:
      true if the OS matches
    • isName

      public static boolean isName(String name)
      Determines if the OS on which Ant is executing matches the given OS name.
      Parameters:
      name - the OS name to check for
      Returns:
      true if the OS matches
    • isArch

      public static boolean isArch(String arch)
      Determines if the OS on which Ant is executing matches the given OS architecture.
      Parameters:
      arch - the OS architecture to check for
      Returns:
      true if the OS matches
    • isVersion

      public static boolean isVersion(String version)
      Determines if the OS on which Ant is executing matches the given OS version.
      Parameters:
      version - the OS version to check for
      Returns:
      true if the OS matches
    • isOs

      private static boolean isOs(String family, String name, String arch, String version)
      Determines if the OS on which Ant is executing matches the given OS family, name, architecture and version
      Parameters:
      family - The OS family
      name - The OS name
      arch - The OS architecture
      version - The OS version
      Returns:
      true if the OS matches
    • getOsFamily

      private static String getOsFamily()
      Helper method to determine the current OS family.
      Returns:
      name of current OS family.
    • isValidFamily

      public static boolean isValidFamily(String family)
      Test if the given family String represents a valid Family
      Parameters:
      family - the os family
      Returns:
      true if 'family' represents a valid OS-Family, false otherwise.