Package org.apache.maven.enforcer.rules
Class BanDependencyManagementScope
- java.lang.Object
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
-
- org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
-
- org.apache.maven.enforcer.rules.BanDependencyManagementScope
-
- All Implemented Interfaces:
EnforcerRuleBase
@Named("banDependencyManagementScope") public final class BanDependencyManagementScope extends AbstractStandardEnforcerRule
This rule bans all scope values except forimport
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
Iftrue
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
-
Constructor Summary
Constructors Constructor Description BanDependencyManagementScope(org.apache.maven.project.MavenProject project)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
This is the interface into the rule.private static java.lang.CharSequence
getErrorMessage(org.apache.maven.project.MavenProject project, org.apache.maven.model.Dependency violatingDependency)
(package private) java.util.List<org.apache.maven.model.Dependency>
getViolatingDependencies(org.apache.maven.model.DependencyManagement depMgmt)
void
setExcludes(java.util.List<java.lang.String> excludes)
java.lang.String
toString()
-
Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessage
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getCacheId, getLevel, getRuleName
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
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 formatgroupId[: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
Iftrue
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
-
-
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 classAbstractEnforcerRule
- Throws:
EnforcerRuleException
- the enforcer rule exceptionEnforcerRuleError
- in order to brake a build immediately
-
getViolatingDependencies
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> excludes)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-