svn commit: r1798819 - in /maven/enforcer/trunk/enforcer-rules/src: main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java site/apt/requireUpperBoundDeps.apt.vm

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

svn commit: r1798819 - in /maven/enforcer/trunk/enforcer-rules/src: main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java site/apt/requireUpperBoundDeps.apt.vm

Stephen Connolly
Author: stephenc
Date: Thu Jun 15 10:57:51 2017
New Revision: 1798819

URL: http://svn.apache.org/viewvc?rev=1798819&view=rev
Log:
[MENFORCER-273] Adding RequireUpperBoundDeps.excludes option.

Submitted by Jesse Glick (jglick at apache dot org)

Modified:
    maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java
    maven/enforcer/trunk/enforcer-rules/src/site/apt/requireUpperBoundDeps.apt.vm

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java?rev=1798819&r1=1798818&r2=1798819&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDeps.java Thu Jun 15 10:57:51 2017
@@ -65,6 +65,13 @@ public class RequireUpperBoundDeps
     private boolean uniqueVersions;
 
     /**
+     * Dependencies to ignore.
+     *
+     * @since TBD
+     */
+    private List<String> excludes = null;
+
+    /**
      * Set to {@code true} if timestamped snapshots should be used.
      *
      * @param uniqueVersions
@@ -75,6 +82,15 @@ public class RequireUpperBoundDeps
         this.uniqueVersions = uniqueVersions;
     }
 
+    /**
+     * Sets dependencies to exclude.
+     * @param excludes a list of {@code groupId:artifactId} names
+     */
+    public void setExcludes( List<String> excludes )
+    {
+        this.excludes = excludes;
+    }
+
     // CHECKSTYLE_OFF: LineLength
     /**
      * Uses the {@link EnforcerRuleHelper} to populate the values of the
@@ -159,7 +175,16 @@ public class RequireUpperBoundDeps
         List<String> errorMessages = new ArrayList<String>( conflicts.size() );
         for ( List<DependencyNode> conflict : conflicts )
         {
-            errorMessages.add( buildErrorMessage( conflict ) );
+            Artifact artifact = conflict.get( 0 ).getArtifact();
+            String groupArt = artifact.getGroupId() + ":" + artifact.getArtifactId();
+            if ( excludes != null && excludes.contains( groupArt ) )
+            {
+                log.info( "Ignoring requireUpperBoundDeps in " + groupArt );
+            }
+            else
+            {
+                errorMessages.add( buildErrorMessage( conflict ) );
+            }
         }
         return errorMessages;
     }

Modified: maven/enforcer/trunk/enforcer-rules/src/site/apt/requireUpperBoundDeps.apt.vm
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/site/apt/requireUpperBoundDeps.apt.vm?rev=1798819&r1=1798818&r2=1798819&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/site/apt/requireUpperBoundDeps.apt.vm (original)
+++ maven/enforcer/trunk/enforcer-rules/src/site/apt/requireUpperBoundDeps.apt.vm Thu Jun 15 10:57:51 2017
@@ -104,6 +104,11 @@ and
                 <requireUpperBoundDeps>
                   <!-- 'uniqueVersions' (default:false) can be set to true if you want to compare the timestamped SNAPSHOTs  -->
                   <!-- <uniqueVersions>true</uniqueVersions> -->
+                  <!-- If you wish to ignore certain cases:
+                  <excludes>
+                    <exclude>com.google.guava:guava</exclude>
+                  </excludes>
+                  -->
                 </requireUpperBoundDeps>
               </rules>
             </configuration>


Loading...