mirror of https://github.com/apache/maven.git
[MNG-4304] [regression] MavenProject.getDependencyArtifacts() not set
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@805008 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2dddfecbfa
commit
00ed1a01c0
|
@ -20,6 +20,8 @@ package org.apache.maven;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
@ -32,6 +34,7 @@ import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.OrArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.OrArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.artifact.ProjectArtifact;
|
import org.apache.maven.project.artifact.ProjectArtifact;
|
||||||
import org.apache.maven.repository.RepositorySystem;
|
import org.apache.maven.repository.RepositorySystem;
|
||||||
|
@ -101,7 +104,26 @@ public class DefaultProjectDependenciesResolver
|
||||||
|
|
||||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||||
resolutionErrorHandler.throwErrors( request, result );
|
resolutionErrorHandler.throwErrors( request, result );
|
||||||
|
|
||||||
project.setArtifacts( result.getArtifacts() );
|
project.setArtifacts( result.getArtifacts() );
|
||||||
|
|
||||||
|
Set<String> directDependencies = new HashSet<String>( project.getDependencies().size() * 2 );
|
||||||
|
for ( Dependency dependency : project.getDependencies() )
|
||||||
|
{
|
||||||
|
directDependencies.add( dependency.getManagementKey() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Artifact> dependencyArtifacts = new LinkedHashSet<Artifact>( project.getDependencies().size() * 2 );
|
||||||
|
for ( Artifact artifact : result.getArtifacts() )
|
||||||
|
{
|
||||||
|
if ( directDependencies.contains( artifact.getDependencyConflictId() ) )
|
||||||
|
{
|
||||||
|
dependencyArtifacts.add( artifact );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.setDependencyArtifacts( dependencyArtifacts );
|
||||||
|
|
||||||
return result.getArtifacts();
|
return result.getArtifacts();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue