diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java index 872ac123ea..470f6f4e7c 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java @@ -382,6 +382,8 @@ public class DefaultLegacyArtifactCollector { fireEvent( ResolutionListener.PROCESS_CHILDREN, listeners, node ); + Artifact parentArtifact = node.getArtifact(); + for ( Iterator i = node.getChildrenIterator(); i.hasNext(); ) { ResolutionNode child = (ResolutionNode) i.next(); @@ -493,6 +495,17 @@ public class DefaultLegacyArtifactCollector } while( !childKey.equals( child.getKey() ) ); + if ( parentArtifact != null && parentArtifact.getDependencyFilter() != null + && !parentArtifact.getDependencyFilter().include( artifact ) ) + { + // MNG-3769: the [probably relocated] artifact is excluded. + // We could process exclusions on relocated artifact details in the + // MavenMetadataSource.createArtifacts(..) step, BUT that would + // require resolving the POM from the repository very early on in + // the build. + continue; + } + artifact.setDependencyTrail( node.getDependencyTrail() ); ResolutionGroup rGroup = source.retrieve( artifact, localRepository, childRemoteRepositories );