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 for
import
from dependencies within the dependency management.
There is a configuration option to ignore certain dependencies in this check.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
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.Specify the dependencies that will be ignored.private final org.apache.maven.project.MavenProject
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
This is the interface into the rule.private static CharSequence
getErrorMessage
(org.apache.maven.project.MavenProject project, org.apache.maven.model.Dependency violatingDependency) protected List
<org.apache.maven.model.Dependency> getViolatingDependencies
(org.apache.maven.model.DependencyManagement depMgmt) void
setExcludes
(List<String> theExcludes) 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
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
Field Details
-
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 checkEffectivePomIftrue
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
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 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
-
toString
-