From acfb2068fe945682e96a4f9bb460ce42f30ab465 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 4 Mar 2019 20:05:04 -0800 Subject: [PATCH] [MSHADE-148] Don't attach exclusions that are already present Although I don't fully understand the scenarios where we re-evaluate the exclusions of a dependency, I do know that if we do, we will add them again, leading to a false indication that the dependency list has changed, leading to a regeneration and re-evaluation of the list, which then continues indefinitely, as the the same exclusions are added again and again. To address the leaf problem, let's ensure that we never add an exclusion that is already present. That way, even if reevaluation occurs, it will not result in changes. --- .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index 6b8d24a6..4a87742d 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -1178,9 +1178,17 @@ public boolean updateExcludesInDeps( MavenProject project, List depe Exclusion exclusion = new Exclusion(); exclusion.setArtifactId( n3.getArtifact().getArtifactId() ); exclusion.setGroupId( n3.getArtifact().getGroupId() ); - dep.addExclusion( exclusion ); - modified = true; - break; + // only add an exclusion if it's not already present. + for ( Exclusion ex : dep.getExclusions() ) + { + if ( !ex.getArtifactId().equals( exclusion.getArtifactId() ) + || !ex.getGroupId().equals( exclusion.getGroupId() ) ) + { + dep.addExclusion( exclusion ); + modified = true; + break; + } + } } } }