org.apache.maven.plugin.enforcer
Class RequireOS

java.lang.Object
  extended by org.apache.maven.plugin.enforcer.RequireOS
All Implemented Interfaces:
org.apache.maven.shared.enforcer.rule.api.EnforcerRule

public class RequireOS
extends java.lang.Object
implements org.apache.maven.shared.enforcer.rule.api.EnforcerRule

This rule checks that the OS is allowed by combinations of family, name, version and cpu architecture. The behavior is exactly the same as the Maven Os profile activation so the same values are allowed here.

Version:
$Id: RequireOS.java 524303 2007-03-30 22:59:32Z brianf $
Author:
Brian Fox

Field Summary
 java.lang.String arch
          Runtime information containing Maven Version.
 boolean display
          Display detected OS information.
 java.lang.String family
          The OS family type desired
Possible values:
dos mac netware os/2 tandem unix windows win9x z/os os/400
 java.lang.String message
          Specify an optional message to the user if the rule fails.
 java.lang.String name
          Runtime information containing Maven Version.
static java.lang.String OS_ARCH
           
static java.lang.String OS_NAME
           
static java.lang.String OS_VERSION
           
 java.lang.String version
          Runtime information containing Maven Version.
 
Constructor Summary
RequireOS()
           
 
Method Summary
 boolean allParamsEmpty()
          Helper method to check that at least one of family, name, version or arch is set.
 java.lang.String determineOsFamily()
          Helper method to determine the current OS family.
 void displayOSInfo(org.apache.maven.plugin.logging.Log log, boolean info)
          Log the current OS information
 void execute(org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper helper)
           
 java.lang.String getArch()
           
 java.lang.String getFamily()
           
 java.lang.String getName()
           
 java.util.Set getValidFamilies()
           
 java.lang.String getVersion()
           
 boolean isAllowed()
          Helper method to determine if the current OS is allowed based on the injected values for family, name, version and arch.
 boolean isValidFamily(java.lang.String theFamily)
          Helper method to check if the given family is in the following list: dos mac netware os/2 tandem unix windows win9x z/os os/400 Note: '!' is allowed at the beginning of the string and still considered valid.
 void setArch(java.lang.String theArch)
           
 void setFamily(java.lang.String theFamily)
           
 void setName(java.lang.String theName)
           
 void setValidFamilies(java.util.Set theValidFamilies)
           
 void setVersion(java.lang.String theVersion)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

family

public java.lang.String family
The OS family type desired
Possible values:


name

public java.lang.String name
Runtime information containing Maven Version.


version

public java.lang.String version
Runtime information containing Maven Version.


arch

public java.lang.String arch
Runtime information containing Maven Version.


message

public java.lang.String message
Specify an optional message to the user if the rule fails.


display

public boolean display
Display detected OS information.


OS_NAME

public static final java.lang.String OS_NAME

OS_ARCH

public static final java.lang.String OS_ARCH

OS_VERSION

public static final java.lang.String OS_VERSION
Constructor Detail

RequireOS

public RequireOS()
Method Detail

execute

public void execute(org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper helper)
             throws org.apache.maven.shared.enforcer.rule.api.EnforcerRuleException
Specified by:
execute in interface org.apache.maven.shared.enforcer.rule.api.EnforcerRule
Throws:
org.apache.maven.shared.enforcer.rule.api.EnforcerRuleException

displayOSInfo

public void displayOSInfo(org.apache.maven.plugin.logging.Log log,
                          boolean info)
Log the current OS information

Parameters:
log -

determineOsFamily

public java.lang.String determineOsFamily()
Helper method to determine the current OS family.

Returns:
name of current OS family.

isAllowed

public boolean isAllowed()
Helper method to determine if the current OS is allowed based on the injected values for family, name, version and arch.

Returns:
true if the version is allowed.

allParamsEmpty

public boolean allParamsEmpty()
Helper method to check that at least one of family, name, version or arch is set.

Returns:
true if all parameters are empty.

isValidFamily

public boolean isValidFamily(java.lang.String theFamily)
Helper method to check if the given family is in the following list: Note: '!' is allowed at the beginning of the string and still considered valid.

Parameters:
theFamily - the family to check.
Returns:
true if one of the valid families.

getArch

public java.lang.String getArch()
Returns:
the arch

setArch

public void setArch(java.lang.String theArch)
Parameters:
theArch - the arch to set

getFamily

public java.lang.String getFamily()
Returns:
the family

setFamily

public void setFamily(java.lang.String theFamily)
Parameters:
theFamily - the family to set

getName

public java.lang.String getName()
Returns:
the name

setName

public void setName(java.lang.String theName)
Parameters:
theName - the name to set

getVersion

public java.lang.String getVersion()
Returns:
the version

setVersion

public void setVersion(java.lang.String theVersion)
Parameters:
theVersion - the version to set

getValidFamilies

public java.util.Set getValidFamilies()
Returns:
the validFamilies

setValidFamilies

public void setValidFamilies(java.util.Set theValidFamilies)
Parameters:
theValidFamilies - the validFamilies to set


Copyright © 2002-2010 Apache Software Foundation. All Rights Reserved.