Class RequireJavaVersion

  • All Implemented Interfaces:
    EnforcerRuleBase

    @Named("requireJavaVersion")
    public final class RequireJavaVersion
    extends AbstractVersionEnforcer
    This rule checks that the Java version is allowed.
    • Field Detail

      • JDK8_VERSION_PATTERN

        private static final java.util.regex.Pattern JDK8_VERSION_PATTERN
      • display

        private boolean display
        Display the normalized JDK version.
    • Constructor Detail

      • RequireJavaVersion

        public RequireJavaVersion()
    • Method Detail

      • setVersion

        public void setVersion​(java.lang.String version)
        Description copied from class: AbstractVersionEnforcer
        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
        Overrides:
        setVersion in class AbstractVersionEnforcer
        Parameters:
        version - the required version to set
      • execute

        public void execute()
                     throws EnforcerRuleException
        Description copied from class: AbstractEnforcerRule
        This 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:
        execute in class AbstractEnforcerRule
        Throws:
        EnforcerRuleException - the enforcer rule exception
        EnforcerRuleError - in order to brake a build immediately
      • normalizeJDKVersion

        public static java.lang.String normalizeJDKVersion​(java.lang.String jdkVersion)
        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
      • setCustomMessageIfNoneConfigured

        private void setCustomMessageIfNoneConfigured​(org.apache.maven.artifact.versioning.ArtifactVersion detectedJdkVersion,
                                                      java.lang.String allowedVersionRange)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object