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 2020/05/07 20:18:23 UTC

[maven] branch MNG-5600-sl created (now 2dc7c03)

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

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


      at 2dc7c03  [MNG-5600] Small refactor

This branch includes the following new commits:

     new 9431086  [MNG-5600] Dependency management import should support exclusions.
     new 2dc7c03  [MNG-5600] Small refactor

The 2 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] 02/02: [MNG-5600] Small refactor

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-sl
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 2dc7c03bf1f79857cbf99389da9d0d83854d559c
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Thu May 7 22:18:08 2020 +0200

    [MNG-5600] Small refactor
---
 .../maven/model/building/DefaultModelBuilder.java   | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

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 092fdb2..2a2adeb 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
@@ -1415,20 +1415,13 @@ public class DefaultModelBuilder
                     {
                         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();
-                                }
-                            }
+                            // Dependency excluded from import.
+                            importMgmt.getDependencies()
+                                    .removeIf( candidate -> (
+                                            exclusion.getGroupId().equals( "*" ) ||
+                                                    exclusion.getGroupId().equals( candidate.getGroupId() ) )
+                                            && ( exclusion.getArtifactId().equals( "*" ) ||
+                                                    exclusion.getArtifactId().equals( candidate.getArtifactId() ) ) );
                         }
                     }
 


[maven] 01/02: [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-sl
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 9431086eabdc450c1fe199a531aad31096cfe7a9
Author: Alex Szakaly <al...@gmail.com>
AuthorDate: Thu May 7 18:50:25 2020 +0200

    [MNG-5600] Dependency management import should support exclusions.
    
    The original patch is made by: Christian Schulte <sc...@apache.org>
---
 .../maven/model/building/DefaultModelBuilder.java  | 36 +++++++++++++++++++++-
 1 file changed, 35 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 b72550b..092fdb2 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
@@ -28,6 +28,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;
@@ -1407,7 +1408,40 @@ public class DefaultModelBuilder
                     importMgmt = new DependencyManagement();
                 }
 
-                intoCache( 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.
+                    intoCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMgmt );
+                }
             }
 
             if ( importMgmts == null )