Class RequireJavaVersion
java.lang.Object
org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
org.apache.maven.enforcer.rules.version.RequireJavaVersion
- All Implemented Interfaces:
EnforcerRuleBase
@Named("requireJavaVersion")
public final class RequireJavaVersion
extends AbstractStandardEnforcerRule
This rule checks that the Java version is allowed.
- Author:
- Brian Fox
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenforceVersion(String variableName, String requiredVersionRange, org.apache.maven.artifact.versioning.ArtifactVersion actualVersion) Compares the specified version to see if it is allowed by the defined version range.voidexecute()This is the interface into the rule.If the rule is to be cached during session scope, whole executing of Maven build, this id is used as part of the key.getLog()Provide anEnforcerLoggerinstance for Rulefinal StringGets the required version.static StringnormalizeJDKVersion(String jdkVersion) Converts a JDK string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11voidsetLog(EnforcerLogger log) Used byEnforcerMojoto inject logger instancevoidsetVersion(String version) Specify the required version.toString()protected static StringtoString(org.apache.maven.artifact.versioning.VersionRange versionRange) Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessageMethods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getLevel, getRuleName
-
Constructor Details
-
RequireJavaVersion
public RequireJavaVersion()
-
-
Method Details
-
setVersion
Specify the required version. Some examples are:2.0.4Version 2.0.4 and higher (different from Maven meaning)[2.0,2.1)Versions 2.0 (included) to 2.1 (not included)[2.0,2.1]Versions 2.0 to 2.1 (both included)[2.0.5,)Versions 2.0.5 and higher(,2.0.5],[2.1.1,)Versions up to 2.0.5 (included) and 2.1.1 or higher
- Parameters:
version- the required version to set
-
execute
Description copied from class:AbstractEnforcerRuleThis is the interface into the rule. This method should throw an exception containing a reason message if the rule fails the check. The plugin will then decide based on the fail flag and rule level if it should stop or just log the message as a warning.- Specified by:
executein classAbstractEnforcerRule- Throws:
EnforcerRuleException- the enforcer rule exception
-
normalizeJDKVersion
Converts a JDK string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11- Parameters:
jdkVersion- to be converted- Returns:
- the converted string
-
toString
-
enforceVersion
public void enforceVersion(String variableName, String requiredVersionRange, org.apache.maven.artifact.versioning.ArtifactVersion actualVersion) throws EnforcerRuleException Compares the specified version to see if it is allowed by the defined version range.- Parameters:
variableName- name of variable to use in messages. For example, "Maven" or "Java".requiredVersionRange- range of allowed versionsactualVersion- the version to be checked- Throws:
EnforcerRuleException- the enforcer rule exception
-
toString
-
getCacheId
Description copied from class:AbstractEnforcerRuleIf the rule is to be cached during session scope, whole executing of Maven build, this id is used as part of the key.Rule of the same class and the same cache id will be executed once.
- Overrides:
getCacheIdin classAbstractEnforcerRule- Returns:
- id to be used by the Enforcer to determine uniqueness of cache results.
Return
nulldisable cache of rule executing.
-
getVersion
Gets the required version.- Returns:
- the required version
-
setLog
Used byEnforcerMojoto inject logger instance- Specified by:
setLogin interfaceEnforcerRuleBase- Parameters:
log- anEnforcerLoggerinstance
-
getLog
Provide anEnforcerLoggerinstance for RuleNOTICE A logger is not available in constructors.
- Returns:
- an
EnforcerLoggerinstance
-