Class BanTransitiveDependencies
- java.lang.Object
-
- org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
-
- org.apache.maven.plugins.enforcer.AbstractNonCacheableEnforcerRule
-
- org.apache.maven.plugins.enforcer.BanTransitiveDependencies
-
- All Implemented Interfaces:
EnforcerRule
,EnforcerRule2
public class BanTransitiveDependencies extends AbstractNonCacheableEnforcerRule implements EnforcerRule
This rule bans all transitive dependencies. There is a configuration option to exclude certain artifacts from being checked.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>
excludes
Specify the dependencies that will be ignored.private EnforcerRuleHelper
helper
private java.util.List<java.lang.String>
includes
Specify the dependencies that will be checked.
-
Constructor Summary
Constructors Constructor Description BanTransitiveDependencies()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private org.apache.maven.shared.dependency.graph.DependencyGraphBuilder
createDependencyGraphBuilder()
void
execute(EnforcerRuleHelper helper)
This is the interface into the rule.private static boolean
searchTree(org.apache.maven.shared.dependency.graph.DependencyNode node, int level, ArtifactMatcher excludes, java.lang.StringBuilder message)
Searches dependency tree recursively for transitive dependencies that are not excluded, while generating nice info message along the way.-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.maven.enforcer.rule.api.EnforcerRule
getCacheId, isCacheable, isResultValid
-
-
-
-
Field Detail
-
helper
private EnforcerRuleHelper helper
-
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')
You can override this patterns by using includes. Version is a string representing standard maven version range. Empty patterns will be ignored.
-
includes
private java.util.List<java.lang.String> includes
Specify the dependencies that will be checked. These are exceptions to excludes intended for more convenient and finer settings. 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.
-
-
Method Detail
-
searchTree
private static boolean searchTree(org.apache.maven.shared.dependency.graph.DependencyNode node, int level, ArtifactMatcher excludes, java.lang.StringBuilder message) throws org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
Searches dependency tree recursively for transitive dependencies that are not excluded, while generating nice info message along the way.- Throws:
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
-
execute
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException
Description copied from interface:EnforcerRule
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 if it should stop or just log the message as a warning.- Specified by:
execute
in interfaceEnforcerRule
- Parameters:
helper
- The helper provides access to the log, MavenSession and has helpers to get common components. It is also able to lookup components by class name.- Throws:
EnforcerRuleException
- the enforcer rule exception
-
createDependencyGraphBuilder
private org.apache.maven.shared.dependency.graph.DependencyGraphBuilder createDependencyGraphBuilder() throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
-
-