Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-beta-1
-
Fix Version/s: 1.0
-
Component/s: Standard Rules
-
Labels:None
-
Environment:Any
-
Patch Submitted:Yes
-
Number of attachments :
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
Issue Links
- relates to
-
MENFORCER-94
Review evaluation of version ranges with regard to inclusion of snapshots
-