Class BanDynamicVersions

All Implemented Interfaces:
EnforcerRuleBase

@Named("banDynamicVersions") public final class BanDynamicVersions extends AbstractStandardEnforcerRule
This rule bans dependencies having a version which requires resolution (i.e. dynamic versions which might change with each build). Dynamic versions are either
  • version ranges,
  • the special placeholders LATEST or RELEASE or
  • versions ending with -SNAPSHOT.
Since:
3.2.0
  • Field Details

    • RELEASE

      private static final String RELEASE
      See Also:
    • LATEST

      private static final String LATEST
      See Also:
    • SNAPSHOT_SUFFIX

      private static final String SNAPSHOT_SUFFIX
      See Also:
    • allowSnapshots

      private boolean allowSnapshots
      true if versions ending with -SNAPSHOT should be allowed
    • allowLatest

      private boolean allowLatest
      true if versions using LATEST should be allowed
    • allowRelease

      private boolean allowRelease
      true if versions using RELEASE should be allowed
    • allowRanges

      private boolean allowRanges
      true if version ranges should be allowed
    • allowRangesWithIdenticalBounds

      private boolean allowRangesWithIdenticalBounds
      true if ranges having the same upper and lower bound like [1.0] should be allowed. Only applicable if allowRanges is not set to true.
    • excludeOptionals

      private boolean excludeOptionals
      true if optional dependencies should not be checked
    • excludedScopes

      private List<String> excludedScopes
      the scopes of dependencies which should be excluded from this rule
    • ignores

      private List<String> ignores
      Specify the ignored dependencies. This can be a list of artifacts in the format groupId[:artifactId[:version[:type[:scope:[classifier]]]]]. Any of the sections can be a wildcard by using '*' (e.g. group:*:1.0).
      Any of the ignored dependencies may have dynamic versions.
    • resolverUtil

      private final ResolverUtil resolverUtil
  • Constructor Details

    • BanDynamicVersions

      @Inject public BanDynamicVersions(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystem repoSystem, org.apache.maven.execution.MavenSession mavenSession, ResolverUtil resolverUtil)
  • Method Details

    • 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
    • dumpIntermediatePath

      private static String dumpIntermediatePath(Collection<org.eclipse.aether.graph.DependencyNode> path)
    • collectDependenciesWithBannedDynamicVersions

      private List<String> collectDependenciesWithBannedDynamicVersions(org.eclipse.aether.graph.DependencyNode rootDependency) throws org.eclipse.aether.collection.DependencyCollectionException
      Throws:
      org.eclipse.aether.collection.DependencyCollectionException
    • toString

      public String toString()
      Overrides:
      toString in class Object