Maven Enforcer Plugin
  1. Maven Enforcer Plugin
  2. MENFORCER-101

Enforcer does not allow to restrict based on SNAPSHOT version as version comparison uses artifact.getVersion() instead of artifact.getBaseVersion()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-1
    • Fix Version/s: 1.0
    • Component/s: Standard Rules
    • Labels:
      None
    • Environment:
      Any
    • Flags:
      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

        Issue Links

          Activity

          Prashant Bhate created issue -
          Dennis Lundberg made changes -
          Field Original Value New Value
          Link This issue relates to MENFORCER-94 [ MENFORCER-94 ]
          Brian Fox made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Fix Version/s 1.0-beta-2 [ 15129 ]
          Resolution Fixed [ 1 ]
          Brian Fox made changes -
          Fix Version/s 1.0-beta-2 [ 15129 ]
          Fix Version/s 1.0 [ 13616 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 10:06:27 UTC 2015 [ 1428228387238 ]
          Mark Thomas made changes -
          Workflow jira [ 12721240 ] Default workflow, editable Closed status [ 12761765 ]
          Mark Thomas made changes -
          Flags Patch [ 10430 ]
          Patch Submitted Yes [ 10763 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 23:50:18 UTC 2015 [ 1428277818417 ]
          Mark Thomas made changes -
          Workflow jira [ 12958728 ] Default workflow, editable Closed status [ 12995651 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Closed Closed
          104d 8h 59m 1 Brian Fox 27/Oct/10 21:40

            People

            • Assignee:
              Unassigned
              Reporter:
              Prashant Bhate
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development