Class BanDynamicVersions
- 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.BanDynamicVersions
-
- All Implemented Interfaces:
EnforcerRuleBase
@Named("banDynamicVersions") public final class BanDynamicVersions extends AbstractStandardEnforcerRule
This rule bans dependencies having a version which requires resolution (i.e. dynamic versions which might change with each build). Dynamic versions are either- version ranges,
- the special placeholders
LATEST
orRELEASE
or - versions ending with
-SNAPSHOT
.
- Since:
- 3.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
BanDynamicVersions.BannedDynamicVersionCollector
private static class
BanDynamicVersions.ExcludeArtifactPatternsPredicate
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowLatest
true
if versions usingLATEST
should be allowedprivate boolean
allowRanges
true
if version ranges should be allowedprivate boolean
allowRangesWithIdenticalBounds
true
if ranges having the same upper and lower bound like[1.0]
should be allowed.private boolean
allowRelease
true
if versions usingRELEASE
should be allowedprivate boolean
allowSnapshots
true
if versions ending with-SNAPSHOT
should be allowedprivate java.util.List<java.lang.String>
excludedScopes
the scopes of dependencies which should be excluded from this ruleprivate boolean
excludeOptionals
true
if optional dependencies should not be checkedprivate java.util.List<java.lang.String>
ignores
Specify the ignored dependencies.private static java.lang.String
LATEST
private static java.lang.String
RELEASE
private ResolverUtil
resolverUtil
private static java.lang.String
SNAPSHOT_SUFFIX
private boolean
verbose
true
if dependencies should be checked before Maven computes the final dependency tree.
-
Constructor Summary
Constructors Constructor Description BanDynamicVersions(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystem repoSystem, org.apache.maven.execution.MavenSession mavenSession, ResolverUtil resolverUtil)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<java.lang.String>
collectDependenciesWithBannedDynamicVersions(org.eclipse.aether.graph.DependencyNode rootDependency)
private static java.lang.String
dumpIntermediatePath(java.util.Collection<org.eclipse.aether.graph.DependencyNode> path)
void
execute()
This is the interface into the rule.void
setVerbose(boolean verbose)
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
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
Field Detail
-
RELEASE
private static final java.lang.String RELEASE
- See Also:
- Constant Field Values
-
LATEST
private static final java.lang.String LATEST
- See Also:
- Constant Field Values
-
SNAPSHOT_SUFFIX
private static final java.lang.String SNAPSHOT_SUFFIX
- See Also:
- Constant Field Values
-
allowSnapshots
private boolean allowSnapshots
true
if versions ending with-SNAPSHOT
should be allowed
-
allowLatest
private boolean allowLatest
true
if versions usingLATEST
should be allowed
-
allowRelease
private boolean allowRelease
true
if versions usingRELEASE
should be allowed
-
allowRanges
private boolean allowRanges
true
if version ranges should be allowed
-
allowRangesWithIdenticalBounds
private boolean allowRangesWithIdenticalBounds
true
if ranges having the same upper and lower bound like[1.0]
should be allowed. Only applicable ifallowRanges
is not set totrue
.
-
excludeOptionals
private boolean excludeOptionals
true
if optional dependencies should not be checked
-
excludedScopes
private java.util.List<java.lang.String> excludedScopes
the scopes of dependencies which should be excluded from this rule
-
ignores
private java.util.List<java.lang.String> ignores
Specify the ignored dependencies. This can be a list of artifacts in the formatgroupId[:artifactId[:version[:type[:scope:[classifier]]]]]
. Any of the sections can be a wildcard by using '*' (e.g.group:*:1.0
).
Any of the ignored dependencies may have dynamic versions.
-
verbose
private boolean verbose
true
if dependencies should be checked before Maven computes the final dependency tree. Setting this property will make the rule check dependencies before any conflicts are resolved. This is similar to theverbose
parameter for thetree
goal formaven-dependency-plugin
.
-
resolverUtil
private final ResolverUtil resolverUtil
-
-
Constructor Detail
-
BanDynamicVersions
@Inject public BanDynamicVersions(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystem repoSystem, org.apache.maven.execution.MavenSession mavenSession, ResolverUtil resolverUtil)
-
-
Method Detail
-
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
-
dumpIntermediatePath
private static java.lang.String dumpIntermediatePath(java.util.Collection<org.eclipse.aether.graph.DependencyNode> path)
-
collectDependenciesWithBannedDynamicVersions
private java.util.List<java.lang.String> collectDependenciesWithBannedDynamicVersions(org.eclipse.aether.graph.DependencyNode rootDependency) throws org.eclipse.aether.collection.DependencyCollectionException
- Throws:
org.eclipse.aether.collection.DependencyCollectionException
-
setVerbose
public void setVerbose(boolean verbose)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-