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 AbstractStandardEnforcerRuleThis 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
LATESTorRELEASEor - versions ending with
-SNAPSHOT.
- Since:
- 3.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classBanDynamicVersions.BannedDynamicVersionCollectorprivate static classBanDynamicVersions.ExcludeArtifactPatternsPredicate
-
Field Summary
Fields Modifier and Type Field Description private booleanallowLatesttrueif versions usingLATESTshould be allowedprivate booleanallowRangestrueif version ranges should be allowedprivate booleanallowRangesWithIdenticalBoundstrueif ranges having the same upper and lower bound like[1.0]should be allowed.private booleanallowReleasetrueif versions usingRELEASEshould be allowedprivate booleanallowSnapshotstrueif versions ending with-SNAPSHOTshould be allowedprivate java.util.List<java.lang.String>excludedScopesthe scopes of dependencies which should be excluded from this ruleprivate booleanexcludeOptionalstrueif optional dependencies should not be checkedprivate java.util.List<java.lang.String>ignoresSpecify the ignored dependencies.private static java.lang.StringLATESTprivate static java.lang.StringRELEASEprivate ResolverUtilresolverUtilprivate static java.lang.StringSNAPSHOT_SUFFIXprivate booleanverbosetrueif 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.StringdumpIntermediatePath(java.util.Collection<org.eclipse.aether.graph.DependencyNode> path)voidexecute()This is the interface into the rule.voidsetVerbose(boolean verbose)java.lang.StringtoString()-
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
-
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
trueif versions ending with-SNAPSHOTshould be allowed
-
allowLatest
private boolean allowLatest
trueif versions usingLATESTshould be allowed
-
allowRelease
private boolean allowRelease
trueif versions usingRELEASEshould be allowed
-
allowRanges
private boolean allowRanges
trueif version ranges should be allowed
-
allowRangesWithIdenticalBounds
private boolean allowRangesWithIdenticalBounds
trueif ranges having the same upper and lower bound like[1.0]should be allowed. Only applicable ifallowRangesis not set totrue.
-
excludeOptionals
private boolean excludeOptionals
trueif 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
trueif 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 theverboseparameter for thetreegoal 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 EnforcerRuleExceptionDescription 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.- Specified by:
executein 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)
-
setVerbose
public void setVerbose(boolean verbose)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-