Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-1
-
None
-
Any
-
Patch
Description
When following restriction is given to banned dependency rule, comparison fails as it compare with actual snapshot version in the repository (which includes timestamp 1.0-20100715.155142-18 ) instead of base version ( which has 1.0-SNAPSHOT )
<build> <plugins> <plugin> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-snapshot-ver</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <bannedDependencies> <searchTransitive>true</searchTransitive> <excludes> <exclude>org.apache.maven.enforcer:enforcer-rules</exclude> </excludes> <includes> <include>org.apache.maven.enforcer:enforcer-rules:[1.0-beta-2-SNAPSHOT]</include> </includes> </bannedDependencies> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin> </plugins> .. .. .. <dependencies> <dependency> <groupId>org.apache.maven.enforcer</groupId> <artifactId>enforcer-rules</artifactId> <version>1.0-beta-2-SNAPSHOT</version> </dependency> </dependencies>
See code snippet below
BannedDependencies.java
try { result = AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( pattern[2] ), new DefaultArtifactVersion( artifact.getVersion() ) ); } catch ( InvalidVersionSpecificationException e ) { throw new EnforcerRuleException( "Invalid Version Range: ", e ); }
replace
new DefaultArtifactVersion( artifact.getVersion() )
with
new DefaultArtifactVersion( artifact.getBaseVersion() )
will solve this issue
Attachments
Issue Links
- relates to
-
MENFORCER-94 Review evaluation of version ranges with regard to inclusion of snapshots
- Closed