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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
enforceVersion
(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.void
execute()
getLog()
final String
Gets the required version.static String
normalizeJDKVersion
(String theJdkVersion) Converts a jdk string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11void
setLog
(EnforcerLogger arg0) void
setVersion
(String theVersion) Specify the required version.toString()
protected static String
toString
(org.apache.maven.artifact.versioning.VersionRange vr) Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessage
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getLevel
-
Constructor Details
-
RequireJavaVersion
public RequireJavaVersion()
-
-
Method Details
-
setVersion
Specify the required version. Some examples are:2.0.4
Version 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:
theVersion
- the required version to set
-
execute
- Specified by:
execute
in classAbstractEnforcerRule
- Throws:
EnforcerRuleException
-
normalizeJDKVersion
Converts a jdk string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11- Parameters:
theJdkVersion
- 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 (Example: "Maven" or "Java" etc).requiredVersionRange
- range of allowed versions.actualVersion
- the version to be checked.- Throws:
EnforcerRuleException
- the enforcer rule exception
-
toString
-
getCacheId
- Overrides:
getCacheId
in classAbstractEnforcerRule
-
getVersion
Gets the required version.- Returns:
- the required version
-
setLog
- Specified by:
setLog
in interfaceEnforcerRuleBase
-
getLog
-