Class BannedDependencies

All Implemented Interfaces:
EnforcerRuleBase

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

    • shouldExclude

      private Predicate<org.apache.maven.artifact.Artifact> shouldExclude
    • shouldInclude

      private Predicate<org.apache.maven.artifact.Artifact> shouldInclude
  • Constructor Details

    • BannedDependencies

      @Inject BannedDependencies(org.apache.maven.execution.MavenSession session, 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.
      Overrides:
      execute in class BannedDependenciesBase
      Throws:
      EnforcerRuleException - the enforcer rule exception
    • validate

      protected boolean validate(org.apache.maven.artifact.Artifact artifact)
      Description copied from class: BannedDependenciesBase
      Validates a dependency artifact if it fulfills the enforcer rule
      Specified by:
      validate in class BannedDependenciesBase
      Parameters:
      artifact - dependency to be checked against the list of excludes
      Returns:
      true if the dependency passes the rule, false if the dependency triggers a validation error
    • getErrorMessage

      protected String getErrorMessage()
      Specified by:
      getErrorMessage in class BannedDependenciesBase
    • toString

      public String toString()
      Overrides:
      toString in class Object