You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2018/12/30 10:49:58 UTC

[maven] branch MNG-5600 created (now a90979b)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MNG-5600
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at a90979b  [MNG-5600] Dependency management import should support exclusions.

This branch includes the following new commits:

     new a90979b  [MNG-5600] Dependency management import should support exclusions.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven] 01/01: [MNG-5600] Dependency management import should support exclusions.

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-5600
in repository https://gitbox.apache.org/repos/asf/maven.git

commit a90979b4a0da1097967b85379ee85e91b21112c9
Author: Christian Schulte <sc...@apache.org>
AuthorDate: Sun Jun 19 16:32:25 2016 +0200

    [MNG-5600] Dependency management import should support exclusions.
---
 .../maven/model/building/DefaultModelBuilder.java  | 46 +++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 8714611..d5b9e4c 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -19,6 +19,16 @@ package org.apache.maven.model.building;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
@@ -27,6 +37,7 @@ import org.apache.maven.model.Activation;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.Exclusion;
 import org.apache.maven.model.InputLocation;
 import org.apache.maven.model.InputSource;
 import org.apache.maven.model.Model;
@@ -1308,7 +1319,40 @@ public class DefaultModelBuilder
                     importMgmt = new DependencyManagement();
                 }
 
-                putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMgmt );
+                // [MNG-5600] Dependency management import should support exclusions.
+                if ( !dependency.getExclusions().isEmpty() )
+                {
+                    for ( final Exclusion exclusion : dependency.getExclusions() )
+                    {
+                        if ( exclusion.getGroupId() != null && exclusion.getArtifactId() != null )
+                        {
+                            for ( final Iterator<Dependency> dependencies = importMgmt.getDependencies().iterator();
+                                  dependencies.hasNext(); )
+                            {
+                                final Dependency candidate = dependencies.next();
+
+                                if ( ( exclusion.getGroupId().equals( "*" )
+                                       || exclusion.getGroupId().equals( candidate.getGroupId() ) )
+                                         && ( exclusion.getArtifactId().equals( "*" )
+                                              || exclusion.getArtifactId().equals( candidate.getArtifactId() ) ) )
+                                {
+                                    // Dependency excluded from import.
+                                    dependencies.remove();
+                                }
+                            }
+                        }
+                    }
+
+                    for ( final Dependency includedDependency : importMgmt.getDependencies() )
+                    {
+                        includedDependency.getExclusions().addAll( dependency.getExclusions() );
+                    }
+                }
+                else
+                {
+                    // Only dependency managements without exclusion processing applied can be cached.
+                    putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMgmt );
+                }
             }
 
             if ( importMgmts == null )