Merged from 433788 on the branch, to fix the case where build extensions don't get resolved when building projects that would be filtered by Maven's core artifact filter...as in the case of some plexus projects, and of maven projects themselves.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@433789 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2006-08-22 22:54:13 +00:00
parent 21b94a2dab
commit e165438db3
1 changed files with 22 additions and 1 deletions

View File

@ -65,12 +65,14 @@ public class DefaultExtensionManager
if ( artifact != null ) if ( artifact != null )
{ {
ArtifactFilter filter = new ProjectArtifactExceptionFilter( artifactFilter, project.getArtifact() );
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( artifact ), ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( artifact ),
project.getArtifact(), project.getArtifact(),
localRepository, localRepository,
project.getRemoteArtifactRepositories(), project.getRemoteArtifactRepositories(),
artifactMetadataSource, artifactMetadataSource,
artifactFilter ); filter );
for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); ) for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
{ {
Artifact a = (Artifact) i.next(); Artifact a = (Artifact) i.next();
@ -87,4 +89,23 @@ public class DefaultExtensionManager
{ {
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
} }
private static final class ProjectArtifactExceptionFilter implements ArtifactFilter
{
private ArtifactFilter passThroughFilter;
private String projectDependencyConflictId;
ProjectArtifactExceptionFilter( ArtifactFilter passThroughFilter, Artifact projectArtifact )
{
this.passThroughFilter = passThroughFilter;
this.projectDependencyConflictId = projectArtifact.getDependencyConflictId();
}
public boolean include(Artifact artifact) {
String depConflictId = artifact.getDependencyConflictId();
return projectDependencyConflictId.equals( depConflictId )
|| passThroughFilter.include( artifact );
}
}
} }