mirror of https://github.com/apache/maven.git
[MNG-8132] Fix BOM dependency exclusions (#1622)
The original patch from MNG-5600 had not been ported to the new model builder
This commit is contained in:
parent
4369fa8dff
commit
182b87c246
|
@ -1288,7 +1288,7 @@ public class DefaultModelBuilder implements ModelBuilder {
|
|||
// Dependency excluded from import.
|
||||
List<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);
|
||||
}
|
||||
|
@ -1296,6 +1296,12 @@ public class DefaultModelBuilder implements ModelBuilder {
|
|||
return importMgmt;
|
||||
}
|
||||
|
||||
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, Dependency candidate) {
|
||||
return match(exclusion.getGroupId(), candidate.getGroupId())
|
||||
&& match(exclusion.getArtifactId(), candidate.getArtifactId());
|
||||
|
|
Loading…
Reference in New Issue