mirror of https://github.com/apache/maven.git
[MNG-8118] Merge BOM exclusions instead of overwriting (#1504)
This commit is contained in:
parent
ba52bfe600
commit
0564480440
|
@ -1812,7 +1812,7 @@ public class DefaultModelBuilder implements ModelBuilder {
|
|||
// Dependency excluded from import.
|
||||
List<org.apache.maven.api.model.Dependency> dependencies = importMgmt.getDependencies().stream()
|
||||
.filter(candidate -> exclusions.stream().noneMatch(exclusion -> match(exclusion, candidate)))
|
||||
.map(candidate -> candidate.withExclusions(exclusions))
|
||||
.map(candidate -> addExclusions(candidate, exclusions))
|
||||
.collect(Collectors.toList());
|
||||
importMgmt = importMgmt.withDependencies(dependencies);
|
||||
}
|
||||
|
@ -1820,6 +1820,12 @@ public class DefaultModelBuilder implements ModelBuilder {
|
|||
return importMgmt != null ? new DependencyManagement(importMgmt) : null;
|
||||
}
|
||||
|
||||
private static org.apache.maven.api.model.Dependency addExclusions(
|
||||
org.apache.maven.api.model.Dependency candidate, List<Exclusion> exclusions) {
|
||||
return candidate.withExclusions(Stream.concat(candidate.getExclusions().stream(), exclusions.stream())
|
||||
.toList());
|
||||
}
|
||||
|
||||
private boolean match(Exclusion exclusion, org.apache.maven.api.model.Dependency candidate) {
|
||||
return match(exclusion.getGroupId(), candidate.getGroupId())
|
||||
&& match(exclusion.getArtifactId(), candidate.getArtifactId());
|
||||
|
|
Loading…
Reference in New Issue