Class BanTransitiveDependencies
- 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.dependency.BanTransitiveDependencies
-
- All Implemented Interfaces:
EnforcerRuleBase
@Named("banTransitiveDependencies") public final class BanTransitiveDependencies extends AbstractStandardEnforcerRule
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 java.util.List<java.lang.String>
includes
Specify the dependencies that will be checked.private ResolverUtil
resolverUtil
private org.apache.maven.execution.MavenSession
session
-
Constructor Summary
Constructors Constructor Description BanTransitiveDependencies(org.apache.maven.execution.MavenSession session, ResolverUtil resolverUtil)
-
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 boolean
searchTree(org.eclipse.aether.graph.DependencyNode node, int level, ArtifactMatcher excludes, java.util.Set<org.eclipse.aether.graph.Dependency> directDependencies, java.lang.StringBuilder message)
Searches dependency tree recursively for transitive dependencies that are not excluded, while generating nice info message along the way.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')
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.
-
session
private final org.apache.maven.execution.MavenSession session
-
resolverUtil
private final ResolverUtil resolverUtil
-
-
Constructor Detail
-
BanTransitiveDependencies
@Inject public BanTransitiveDependencies(org.apache.maven.execution.MavenSession session, ResolverUtil resolverUtil)
-
-
Method Detail
-
searchTree
private static boolean searchTree(org.eclipse.aether.graph.DependencyNode node, int level, ArtifactMatcher excludes, java.util.Set<org.eclipse.aether.graph.Dependency> directDependencies, java.lang.StringBuilder message)
Searches dependency tree recursively for transitive dependencies that are not excluded, while generating nice info message along the way.
-
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-