Class AbstractVersionEnforcer
- java.lang.Object
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
-
- org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
-
- org.apache.maven.enforcer.rules.version.AbstractVersionEnforcer
-
- All Implemented Interfaces:
EnforcerRuleBase
- Direct Known Subclasses:
RequireJavaVersion
,RequireMavenVersion
abstract class AbstractVersionEnforcer extends AbstractStandardEnforcerRule
Contains the common code to compare a version against a version range.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
version
Specify the required version.
-
Constructor Summary
Constructors Constructor Description AbstractVersionEnforcer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enforceVersion(java.lang.String variableName, java.lang.String requiredVersionRange, org.apache.maven.artifact.versioning.ArtifactVersion actualVersion)
Compares the specified version to see if it is allowed by the defined version range.java.lang.String
getCacheId()
If the rule is to be cached during session scope, whole executing of Maven build, this id is used as part of the key.java.lang.String
getVersion()
Gets the required version.void
setVersion(java.lang.String version)
Specify the required version.protected static java.lang.String
toString(org.apache.maven.artifact.versioning.VersionRange versionRange)
-
Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessage
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
execute, getLevel, getRuleName
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
Field Detail
-
version
private java.lang.String version
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
-
-
Method Detail
-
enforceVersion
public void enforceVersion(java.lang.String variableName, java.lang.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
protected static java.lang.String toString(org.apache.maven.artifact.versioning.VersionRange versionRange)
-
getCacheId
public java.lang.String getCacheId()
Description copied from class:AbstractEnforcerRule
If 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:
getCacheId
in classAbstractEnforcerRule
- Returns:
- id to be used by the Enforcer to determine uniqueness of cache results.
Return
null
disable cache of rule executing.
-
getVersion
public final java.lang.String getVersion()
Gets the required version.- Returns:
- the required version
-
setVersion
public void setVersion(java.lang.String version)
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:
version
- the required version to set
-
-