Class BannedDependencies
java.lang.Object
org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
org.apache.maven.plugins.enforcer.AbstractNonCacheableEnforcerRule
org.apache.maven.plugins.enforcer.AbstractBanDependencies
org.apache.maven.plugins.enforcer.BannedDependencies
- All Implemented Interfaces:
EnforcerRule
,EnforcerRule2
- Direct Known Subclasses:
BannedPlugins
This rule checks that lists of dependencies are not included.
- Version:
- $Id: BannedDependencies.java 1697215 2015-08-23 16:27:17Z khmarbaise $
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Set<org.apache.maven.artifact.Artifact>
checkDependencies
(Set<org.apache.maven.artifact.Artifact> dependencies, List<String> thePatterns) Checks the set of dependencies against the list of patterns.protected Set<org.apache.maven.artifact.Artifact>
checkDependencies
(Set<org.apache.maven.artifact.Artifact> theDependencies, org.apache.maven.plugin.logging.Log log) Checks the set of dependencies against the list of excludes.protected boolean
compareDependency
(String pattern, org.apache.maven.artifact.Artifact artifact) Compares the given pattern against the given artifact.Gets the excludes.Gets the includes.void
setExcludes
(List<String> theExcludes) Specify the banned dependencies.void
setIncludes
(List<String> theIncludes) Specify the allowed dependencies.Methods inherited from class org.apache.maven.plugins.enforcer.AbstractBanDependencies
execute, getDependenciesToCheck, getErrorMessage, isSearchTransitive, setSearchTransitive
Methods inherited from class org.apache.maven.plugins.enforcer.AbstractNonCacheableEnforcerRule
getCacheId, isCacheable, isResultValid
Methods inherited from class org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
getLevel, getMessage, setLevel, setMessage
-
Field Details
-
excludes
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. -
includes
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"
-
-
Constructor Details
-
BannedDependencies
public BannedDependencies()
-
-
Method Details
-
checkDependencies
protected Set<org.apache.maven.artifact.Artifact> checkDependencies(Set<org.apache.maven.artifact.Artifact> theDependencies, org.apache.maven.plugin.logging.Log log) throws EnforcerRuleException Checks the set of dependencies against the list of excludes.- Specified by:
checkDependencies
in classAbstractBanDependencies
- Parameters:
theDependencies
- the dependencieslog
- the log- Returns:
- the sets the
- Throws:
EnforcerRuleException
- the enforcer rule exception
-
checkDependencies
private Set<org.apache.maven.artifact.Artifact> checkDependencies(Set<org.apache.maven.artifact.Artifact> dependencies, List<String> thePatterns) throws EnforcerRuleException Checks the set of dependencies against the list of patterns.- Parameters:
thePatterns
- the patternsdependencies
- the dependencies- Returns:
- a set containing artifacts matching one of the patterns or
null
- Throws:
EnforcerRuleException
- the enforcer rule exception
-
compareDependency
protected boolean compareDependency(String pattern, org.apache.maven.artifact.Artifact artifact) throws EnforcerRuleException Compares the given pattern against the given artifact. The pattern should follow the formatgroupId:artifactId:version:type:scope:classifier
.- Parameters:
pattern
- The pattern to compare the artifact with.artifact
- the artifact- Returns:
true
if the artifact matches one of the patterns- Throws:
EnforcerRuleException
- the enforcer rule exception
-
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:
theExcludes
- 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:
theIncludes
- the includes to set- See Also:
-