Ban Dynamic Versions
This rule bans dependencies having versions that require resolving (i.e. dynamic versions which might change with each build and require lookup of repository metadata). Dynamic versions are either
- version ranges, i.e. all version strings starting with either
[or(, - the special placeholders
LATEST/RELEASEor - versions ending with
-SNAPSHOT.
The following parameters are supported by this rule:
- allowSnapshots - if
truedependencies with versions ending with-SNAPSHOTwill not be banned. Default isfalse. - allowRelease - if
truedependencies with version placeholderRELEASEwill not be banned. Default isfalse. - allowLatest - if
truedependencies with versions placeholderLATESTwill not be banned. Default isfalse. - allowRanges - if
trueversions starting with either[or(will not be banned. Default isfalse. - allowRangesWithIdenticalBounds - if
trueranges having a range with same upper and lower bound (always inclusive) will not be banned (although they require resolving in some Maven versions, MNG-7461). - excludeOptionals - if
truedirect optional dependencies won't be checked. Default isfalse. - excludedScopes - the list of scopes to exclude from direct dependencies. By default no scopes are excluded. For transitive dependencies the regular Maven rules are applied.
- ignores - a list of dependencies to ignore. The format is
groupId[:artifactId[:version[:type[:scope:[classifier]]]]]whereartifactId,version,type,scopeandclassifierare optional (but require all previous parts). Wildcards may be used to replace an entire or just parts of a section. Examples:org.apache.mavenorg.apache.maven:someArtifactorg.apache.maven:artifact:someVersionorg.apache.maven:*:*:jar:test*:*:*:jar:compile:testsorg.apache.*:maven-*:*
- verbose - if
truethe dependency tree is 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. Default isfalse.
Sample Plugin Configuration:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.6.2</version>
<executions>
<execution>
<id>ban-dynamic-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<banDynamicVersions>
<ignores>
<ignore>org.apache.maven</ignore>
</ignores>
<allowSnapshots>true</allowSnapshots>
</banDynamicVersions>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>


