org.apache.maven.plugin.enforcer
Class AbstractVersionEnforcer

java.lang.Object
  extended by org.apache.maven.plugin.enforcer.AbstractVersionEnforcer
Direct Known Subclasses:
RequireJavaVersion, RequireMavenVersion

public abstract class AbstractVersionEnforcer
extends java.lang.Object

Containts the common code to compare a version against a version range.

Version:
$Id: AbstractVersionEnforcer.java 546361 2007-06-12 02:50:52Z brianf $
Author:
Brian Fox

Field Summary
 java.lang.String message
          Specify an optional message to the user if the rule fails.
 java.lang.String version
          Specify the required version.
 
Constructor Summary
AbstractVersionEnforcer()
           
 
Method Summary
 boolean containsVersion(org.apache.maven.artifact.versioning.VersionRange allowedRange, org.apache.maven.artifact.versioning.ArtifactVersion theVersion)
          Copied from Artifact.VersionRange.
 void enforceVersion(org.apache.maven.plugin.logging.Log log, 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 getVersion()
           
 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

version

public java.lang.String version
Specify the required version. Some examples are


message

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

Constructor Detail

AbstractVersionEnforcer

public AbstractVersionEnforcer()
Method Detail

enforceVersion

public void enforceVersion(org.apache.maven.plugin.logging.Log log,
                           java.lang.String variableName,
                           java.lang.String requiredVersionRange,
                           org.apache.maven.artifact.versioning.ArtifactVersion actualVersion)
                    throws org.apache.maven.shared.enforcer.rule.api.EnforcerRuleException
Compares the specified version to see if it is allowed by the defined version range.

Parameters:
log -
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:
org.apache.maven.plugin.MojoExecutionException - if the version is not allowed.
org.apache.maven.shared.enforcer.rule.api.EnforcerRuleException

containsVersion

public boolean containsVersion(org.apache.maven.artifact.versioning.VersionRange allowedRange,
                               org.apache.maven.artifact.versioning.ArtifactVersion theVersion)
Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently the default containsVersion method assumes a singular version means allow everything. This method assumes that "2.0.4" == "[2.0.4,)"

Parameters:
allowedRange - range of allowed versions.
theVersion - the version to be checked.
Returns:
true if the version is contained by the range.

getVersion

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

setVersion

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


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