Class BannedDependencies
java.lang.Object
org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
org.apache.maven.enforcer.rules.dependency.BannedDependencies
- All Implemented Interfaces:
EnforcerRuleBase
@Named("bannedDependencies")
public final class BannedDependencies
extends AbstractStandardEnforcerRule
This rule checks that lists of dependencies are not included.
- Author:
- Brian Fox
-
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()This is the interface into the rule.protected StringGets the excludes.Gets the includes.getLog()Provide anEnforcerLoggerinstance for Ruleprotected org.apache.maven.execution.MavenSessionbooleanvoidsetExcludes(List<String> excludes) Specify the banned dependencies.voidsetIncludes(List<String> includes) Specify the allowed dependencies.voidsetLog(EnforcerLogger log) Used byEnforcerMojoto inject logger instancevoidsetSearchTransitive(boolean searchTransitive) Sets the search transitive.toString()protected booleanvalidate(org.apache.maven.artifact.Artifact artifact) Validates a dependency artifact if it fulfills the enforcer ruleprotected booleanvalidate(org.eclipse.aether.graph.DependencyNode node, int level, StringBuilder messageBuilder, Set<ArtifactMatcher.MatchingArtifact> visitedArtifacts) Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessageMethods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getCacheId, getLevel, getRuleName
-
Method Details
-
execute
Description copied from class:AbstractEnforcerRuleThis 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.- Throws:
EnforcerRuleException- the enforcer rule exception
-
validate
Validates a dependency artifact if it fulfills the enforcer rule- Parameters:
artifact- dependency to be checked against the list of excludes- Returns:
trueif the dependency passes the rule,falseif the dependency triggers a validation error
-
getErrorMessage
-
toString
-
getSession
protected org.apache.maven.execution.MavenSession getSession() -
validate
protected boolean validate(org.eclipse.aether.graph.DependencyNode node, int level, StringBuilder messageBuilder, Set<ArtifactMatcher.MatchingArtifact> visitedArtifacts) -
setSearchTransitive
public void setSearchTransitive(boolean searchTransitive) Sets the search transitive.- Parameters:
searchTransitive- the searchTransitive to set
-
getExcludes
Gets the excludes.- Returns:
- the excludes
-
setExcludes
Specify the banned dependencies. This can be a list of artifacts in the formatgroupId[:artifactId][:version]. Any of the sections can be a wildcard by using '*' (ie group:*:1.0)
The rule will fail if any dependency matches any exclude, unless it also matches an include rule.- Parameters:
excludes- the excludes to set- See Also:
-
getIncludes
Gets the includes.- Returns:
- the includes
-
setIncludes
Specify the allowed dependencies. This can be a list of artifacts in the formatgroupId[:artifactId][:version]. Any of the sections can be a wildcard by using '*' (ie group:*:1.0)
Includes override the exclude rules. It is meant to allow wide exclusion rules with wildcards and still allow a smaller set of includes.
For example, to ban all xerces except xerces-api → exclude "xerces", include "xerces:xerces-api"- Parameters:
includes- the includes to set- See Also:
-
isSearchTransitive
public boolean isSearchTransitive() -
setLog
Used byEnforcerMojoto inject logger instance- Specified by:
setLogin interfaceEnforcerRuleBase- Parameters:
log- anEnforcerLoggerinstance
-
getLog
Provide anEnforcerLoggerinstance for RuleNOTICE A logger is not available in constructors.
- Returns:
- an
EnforcerLoggerinstance
-