You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Brian Fox (JIRA)" <ji...@codehaus.org> on 2010/10/28 03:42:05 UTC

[jira] Closed: (MENFORCER-101) Enforcer does not allow to restrict based on SNAPSHOT version as version comparison uses artifact.getVersion() instead of artifact.getBaseVersion()

     [ http://jira.codehaus.org/browse/MENFORCER-101?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian Fox closed MENFORCER-101.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 1.0-beta-2

> Enforcer does not allow to restrict based on SNAPSHOT version as version comparison uses artifact.getVersion() instead of artifact.getBaseVersion()
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MENFORCER-101
>                 URL: http://jira.codehaus.org/browse/MENFORCER-101
>             Project: Maven 2.x Enforcer Plugin
>          Issue Type: Bug
>          Components: Standard Rules
>    Affects Versions: 1.0-beta-1
>         Environment: Any
>            Reporter: Prashant  Bhate
>             Fix For: 1.0-beta-2
>
>
> 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 )
> {code:xml}
> <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>
> {code}
> See code snippet below 
> {code:title=BannedDependencies.java|borderStyle=solid}
> try
> {
>  result = AbstractVersionEnforcer.containsVersion( 
>             VersionRange.createFromVersionSpec( pattern[2] ),
>             new DefaultArtifactVersion(  artifact.getVersion() ) 
>           );
> }
> catch ( InvalidVersionSpecificationException e )
> {
> throw new EnforcerRuleException( "Invalid Version Range: ", e );
> }
> {code}
>  replace  
> {code}
>  new DefaultArtifactVersion(  artifact.getVersion() ) 
> {code}
>  with 
> {code}
>  new DefaultArtifactVersion(  artifact.getBaseVersion() )
> {code}
> will solve this issue

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira