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 Summary

      Fields 
      Modifier and Type Field Description
      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.
      private java.util.List<java.lang.String> excludes
      Specify the dependencies that will be ignored.
      private org.apache.maven.project.MavenProject project  
    • Field Detail

      • excludes

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

      • BanDependencyManagementScope

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

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

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

        public void setExcludes​(java.util.List<java.lang.String> theExcludes)
      • toString

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