{
Set projectArtifacts = new LinkedHashSet( dependencies.size() );
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
Dependency d = (Dependency) i.next();
String scope = d.getScope();
if ( StringUtils.isEmpty( scope ) )
{
scope = Artifact.SCOPE_COMPILE;
d.setScope( scope );
}
VersionRange versionRange;
try
{
versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
}
catch ( InvalidVersionSpecificationException e )
{
throw new InvalidDependencyVersionException( "Unable to parse version '" + d.getVersion() +
"' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e );
}
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(), d.getClassifier(),
scope, inheritedScope, d.isOptional() );
if ( Artifact.SCOPE_SYSTEM.equals( scope ) )
{
artifact.setFile( new File( d.getSystemPath() ) );
}
ArtifactFilter artifactFilter = dependencyFilter;
// MNG-3769: It would be nice to be able to process relocations here,
// so we could have this filtering step apply to post-relocated dependencies.
// HOWEVER, this would require a much more invasive POM resolution process
// in order to look for relocations, which would make the early steps in
// a Maven build way too heavy.
if ( artifact != null && ( artifactFilter == null || artifactFilter.include( artifact ) ) )
{
if ( d.getExclusions() != null && !d.getExclusions().isEmpty() )
{
List exclusions = new ArrayList();
for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); )
{
Exclusion e = (Exclusion) j.next();
exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
}