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 Detail

      • 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 java.util.List<java.lang.String> excludedScopes
        the scopes of dependencies which should be excluded from this rule
      • ignores

        private java.util.List<java.lang.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.
      • verbose

        private boolean verbose
        true if dependencies should be checked before Maven computes the final dependency tree. Setting this property will make the rule check dependencies before any conflicts are resolved. This is similar to the verbose parameter for the tree goal for maven-dependency-plugin.
    • Constructor Detail

      • BanDynamicVersions

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

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

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

        private java.util.List<java.lang.String> collectDependenciesWithBannedDynamicVersions​(org.eclipse.aether.graph.DependencyNode rootDependency)
      • setVerbose

        public void setVerbose​(boolean verbose)
      • toString

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