[MNG-5600] Dependency management import should support exclusions.#148
Closed
ChristianSchulte wants to merge 1 commit intoapache:masterfrom
Closed
[MNG-5600] Dependency management import should support exclusions.#148ChristianSchulte wants to merge 1 commit intoapache:masterfrom
ChristianSchulte wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
Author
|
@ChristianSchulte - Any update on when this can/will be merged?? I'm unfamiliar with the maven contribution process |
|
@olamy @rfscholte - Could we get this patch being merged? If any help is needed don't hesitate to ping me. Here is @ChristianSchulte's updated patch without conflict: 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 f981944f940fcbc912959752d3cff4bc1586519f..2a65bbe9ac14a01dac0c49d900c3fbeef052f6a3 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
@@ -27,6 +27,7 @@
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;
@@ -1316,7 +1317,40 @@ private void importDependencyManagement( Model model, ModelBuildingRequest reque
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 ) |
Member
|
@alex1989hu please provide another pr |
pzygielo
pushed a commit
to pzygielo/maven
that referenced
this pull request
Jan 4, 2023
… dependency in profile which is managed by <dependencyManagement> (apache#155) * Fixes apache#145, apache#148 add codes to parse the <version> for the dependency in profile which is managed by <dependencyManagement> * remove redundant code * add empty line at the end of files * remove profile-with-deps-inherit-parent-depMgmt-ci test * consolidate two blocks of code change into createCleanPom method * restore import change * restore import change * add test profile-with-deps-inherit-parent-depMgmt-flatten-dep-all-oss * change test profile-with-deps-inherit-parent-depMgmt-flatten-dep-all-oss to profile-with-deps-inherit-parent-depMgmt-flatten-dep-all-oss-bom * code style fix * fix indents and licenses declaration in verify.groovy * set scope as compile and optional as false if not specified * fix scope and optional - code style Co-authored-by: yangnuoyu <yangnuoyu@penguin>
|
Resolve #6722 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.