Class EnforceBytecodeVersion

All Implemented Interfaces:
EnforcerRuleBase

@Priority(10) @Named("enforceBytecodeVersion") public class EnforceBytecodeVersion extends AbstractStandardEnforcerRule
Enforcer rule that will check the bytecode version of each class of each dependency.
Since:
3.6.3
See Also:
  • Field Details

    • DEFAULT_CLASSES_IGNORE_BEFORE_JDK_9

      private static final String[] DEFAULT_CLASSES_IGNORE_BEFORE_JDK_9
      Default ignores when validating against jdk invalid input: '<' 9 because module-info.class will always have level 1.9.
    • MULTI_RELEASE

      private static final Pattern MULTI_RELEASE
    • JDK_TO_MAJOR_VERSION_NUMBER_MAPPING

      private static final Map<String,Integer> JDK_TO_MAJOR_VERSION_NUMBER_MAPPING
    • message

      private String message
      Custom message, optional. If configured, will be present on first line of the error message.
    • maxJdkVersion

      private String maxJdkVersion
      JDK version as used for example in the maven-compiler-plugin: 8, 11 and so on. If in need of more precise configuration please see maxJavaMajorVersionNumber and maxJavaMinorVersionNumber Mandatory if maxJavaMajorVersionNumber not specified.
    • maxJavaMajorVersionNumber

      private int maxJavaMajorVersionNumber
      If unsure, don't use that parameter. Better look at maxJdkVersion. Mandatory if maxJdkVersion is not specified. see http://en.wikipedia.org/wiki/Java_class_file#General_layout
    • maxJavaMinorVersionNumber

      private int maxJavaMinorVersionNumber
      This parameter is here for potentially advanced use cases, but it seems like it is actually always 0.
      See Also:
    • excludes

      private List<String> excludes
      Specify the excluded dependencies. This can be a list of artifacts in the format groupId[:artifactId][:version]. Any of the sections can be a wildcard by using '*' (ie group:*:1.0)
    • includes

      private List<String> includes
      Specify the included dependencies. This can be a list of artifacts in the format groupId[:artifactId][:version]. Any of the sections can be a wildcard by using '*' (ie group:*:1.0)
      Includes override the exclude rules. It is meant to allow wide exclusion rules with wildcards and still allow a smaller set of includes.
      For example, to ban all xerces except xerces-api -> exclude "xerces", include "xerces:xerces-api"
    • ignoreClasses

      private List<String> ignoreClasses
      List of classes to fully ignore, interpreted as regular expression.
    • scopes

      private List<String> scopes
      List of dependency scopes, to include dependencies in it. Default is to include all scopes.
    • ignoredScopes

      private List<String> ignoredScopes
      List of dependency scopes, to ignore dependencies in it. Default is to not exclude any scope. Excluding scopes like ["test", "provided"] is usually right thing to do.
    • ignoreOptionals

      private boolean ignoreOptionals
      If set, will ignore optional dependencies of the project.
    • searchTransitive

      private boolean searchTransitive
      If set, transitive hull of project is being processed, otherwise only direct dependencies. Default is true.
    • strict

      private boolean strict
      Process module-info and Multi-Release JAR classes if true.
    • processOncePerSession

      private boolean processOncePerSession
      Optimization to calculate same JAR with same options once per session, by default is enabled.
    • ignorableClassesPatterns

      private final List<String> ignorableClassesPatterns
      Internal: strings (regexp expressions) are collected here to ignore matched classes.
    • session

      private final org.apache.maven.execution.MavenSession session
    • resolverUtil

      private final ResolverUtil resolverUtil
  • Constructor Details

    • EnforceBytecodeVersion

      @Inject EnforceBytecodeVersion(org.apache.maven.execution.MavenSession session, ResolverUtil resolverUtil)
  • Method Details