Class BanDependencyManagementScope

All Implemented Interfaces:
EnforcerRuleBase

@Named("banDependencyManagementScope") public final class BanDependencyManagementScope extends AbstractStandardEnforcerRule
This rule bans all scope values except for import from dependencies within the dependency management. There is a configuration option to ignore certain dependencies in this check.
  • Field Details

    • excludes

      private List<String> excludes
      Specify the dependencies that will be ignored. This can be a list of artifacts in the format groupId[:artifactId][:version][:type][:scope]. Wildcard '*' can be used to in place of specific section (ie group:*:1.0 will match both 'group:artifact:1.0' and 'group:anotherArtifact:1.0'). Version is a string representing standard Maven version range. Empty patterns will be ignored.
    • checkEffectivePom

      private boolean checkEffectivePom
      If true the dependencyManagement from imported dependencyManagement and parent pom's is checked as well, otherwise only the local dependencyManagement defined in the current project's pom.xml.
    • project

      private final org.apache.maven.project.MavenProject project
  • Constructor Details

    • BanDependencyManagementScope

      @Inject public BanDependencyManagementScope(org.apache.maven.project.MavenProject project)
  • 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
    • getViolatingDependencies

      protected List<org.apache.maven.model.Dependency> getViolatingDependencies(org.apache.maven.model.DependencyManagement depMgmt)
    • getErrorMessage

      private static CharSequence getErrorMessage(org.apache.maven.project.MavenProject project, org.apache.maven.model.Dependency violatingDependency)
    • setExcludes

      public void setExcludes(List<String> theExcludes)
    • toString

      public String toString()
      Overrides:
      toString in class Object