Class BannedDependencies

All Implemented Interfaces:

@Named("bannedDependencies") public final class BannedDependencies extends AbstractStandardEnforcerRule
This rule checks that lists of dependencies are not included.
Brian Fox
  • Method Details

    • validate

      protected boolean validate(org.apache.maven.artifact.Artifact artifact)
      Validates a dependency artifact if it fulfills the enforcer rule
      artifact - dependency to be checked against the list of excludes
      true if the dependency passes the rule, false if the dependency triggers a validation error
    • getErrorMessage

      protected String getErrorMessage()
    • toString

      public String toString()
      toString in class Object
    • getSession

      protected org.apache.maven.execution.MavenSession getSession()
    • 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
      EnforcerRuleException - the enforcer rule exception
    • validate

      protected boolean validate(org.eclipse.aether.graph.DependencyNode node, int level, StringBuilder messageBuilder)
    • setSearchTransitive

      public void setSearchTransitive(boolean theSearchTransitive)
      Sets the search transitive.
      theSearchTransitive - the searchTransitive to set
    • getExcludes

      public List<String> getExcludes()
      Gets the excludes.
      the excludes
    • setExcludes

      public void setExcludes(List<String> theExcludes)
      Specify the banned 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)
      The rule will fail if any dependency matches any exclude, unless it also matches an include rule.
      theExcludes - the excludes to set
      See Also:
    • getIncludes

      public List<String> getIncludes()
      Gets the includes.
      the includes
    • setIncludes

      public void setIncludes(List<String> theIncludes)
      Specify the allowed 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"
      theIncludes - the includes to set
      See Also:
    • isSearchTransitive

      public boolean isSearchTransitive()
    • setLog

      public void setLog(EnforcerLogger log)
      Used by EnforcerMojo to inject logger instance
      Specified by:
      setLog in interface EnforcerRuleBase
      log - an EnforcerLogger instance
    • getLog

      public EnforcerLogger getLog()
      Provide an EnforcerLogger instance for Rule

      NOTICE A logger is not available in constructors.

      an EnforcerLogger instance