better dep handling in mboot

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163776 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-05 05:28:26 +00:00
parent 935cda15da
commit 2df5479951
1 changed files with 24 additions and 5 deletions

View File

@ -92,6 +92,8 @@ public class ModelReader
private Map transitiveDependencies = new HashMap();
private boolean insideDependencyManagement = false;
public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies )
{
this.downloader = downloader;
@ -132,9 +134,16 @@ public class ModelReader
}
else if ( rawName.equals( "dependency" ) )
{
currentDependency = new Dependency();
if ( !insideDependencyManagement )
{
currentDependency = new Dependency();
insideDependency = true;
insideDependency = true;
}
}
else if ( rawName.equals( "dependencyManagement" ) )
{
insideDependencyManagement = true;
}
else if ( rawName.equals( "resource" ) )
{
@ -195,7 +204,7 @@ public class ModelReader
// actually, these should be transtive (see MNG-77) - but some projects have circular deps that way (marmalade, and currently m2)
ModelReader p = retrievePom( parentGroupId, parentArtifactId, parentVersion, false );
addDependencies( p.getDependencies(), parentDependencies );
addDependencies( p.getDependencies(), parentDependencies, null );
resources.addAll( p.getResources() );
@ -212,11 +221,15 @@ public class ModelReader
ModelReader p = retrievePom( currentDependency.getGroupId(), currentDependency.getArtifactId(),
currentDependency.getVersion(), resolveTransitiveDependencies );
addDependencies( p.getDependencies(), transitiveDependencies );
addDependencies( p.getDependencies(), transitiveDependencies, currentDependency.getScope() );
}
}
dependencies.put( currentDependency.getConflictId(), currentDependency );
}
else if ( rawName.equals( "dependencyManagement" ) )
{
insideDependencyManagement = false;
}
else if ( rawName.equals( "resource" ) )
{
resources.add( currentResource );
@ -332,12 +345,18 @@ public class ModelReader
depth--;
}
private void addDependencies( Collection dependencies, Map target )
private void addDependencies( Collection dependencies, Map target, String inheritedScope )
{
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
Dependency d = (Dependency) i.next();
// Do we care about runtime here?
if ( "test".equals( inheritedScope ) )
{
d.setScope( "test" );
}
if ( !hasDependency( d, target ) )
{
target.put( d.getConflictId(), d );