Some cleanup and added tests for distributionManagement

so scp:// repo's etc. aren't added.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@420413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kenney Westerhof 2006-07-10 04:02:28 +00:00
parent c7c6b5d7c7
commit 74369ff5a3
3 changed files with 54 additions and 29 deletions

View File

@ -33,12 +33,6 @@ import java.util.Set;
*/
public class Model
{
private Map dependencies = new HashMap();
Map parentDependencies = new HashMap();
Map transitiveDependencies = new HashMap();
private Map plugins = new HashMap();
private String artifactId;
@ -63,7 +57,13 @@ public class Model
private Set repositories = new HashSet();
Map managedDependencies = new HashMap();
private Map dependencies = new HashMap();
private Map parentDependencies = new HashMap();
private Map transitiveDependencies = new HashMap();
private Map managedDependencies = new HashMap();
private List chain;
@ -183,13 +183,6 @@ public class Model
return repositories;
}
public Collection getManagedDependencies()
{
Map m = new HashMap();
m.putAll( managedDependencies );
return m.values();
}
public Collection getAllDependencies()
{
Map m = new HashMap();
@ -209,6 +202,28 @@ public class Model
return dependencies;
}
public Map getParentDependencies()
{
return parentDependencies;
}
public Map getTransitiveDependencies()
{
return transitiveDependencies;
}
public Map getManagedDependencies()
{
return managedDependencies;
}
public Collection getManagedDependenciesCollection()
{
Map m = new HashMap();
m.putAll( managedDependencies );
return m.values();
}
public String toString()
{
return "Model[" + getId() + "]";

View File

@ -45,13 +45,13 @@ public class ModelReader
private Resource currentResource;
private boolean insideParent = false;
private boolean insideParent;
private boolean insideDependency = false;
private boolean insideDependency;
private boolean insideResource = false;
private boolean insideResource;
private boolean insideRepository = false;
private boolean insideRepository;
private StringBuffer bodyText = new StringBuffer();
@ -61,7 +61,9 @@ public class ModelReader
private final ArtifactResolver resolver;
private boolean insideDependencyManagement = false;
private boolean insideDependencyManagement;
private boolean insideDistributionManagement;
private boolean insideReleases;
@ -125,8 +127,6 @@ public class ModelReader
}
else if ( rawName.equals( "dependency" ) )
{
// List newChain = Collections.singletonList( new Dependency( model.getGroupId(), model.getArtifactId(), model
// .getVersion(), model.getPackaging(), this.chain ) );
currentDependency = new Dependency( model.getChain() );
insideDependency = true;
@ -145,6 +145,10 @@ public class ModelReader
{
insideDependencyManagement = true;
}
else if ( rawName.equals( "distributionManagement" ) )
{
insideDistributionManagement = true;
}
else if ( rawName.equals( "resource" ) )
{
currentResource = new Resource();
@ -219,13 +223,12 @@ public class ModelReader
model.setVersion( model.getParentVersion() );
}
// actually, these should be transtive (see MNG-77) - but some projects have circular deps that way
Model p = ProjectResolver.retrievePom( resolver, model.getParentGroupId(), model.getParentArtifactId(),
model.getParentVersion(), inheritedScope, false, excluded, model.getChain() );//Collections.singletonList( model ) );
model.getParentVersion(), inheritedScope, false, excluded, model.getChain() );
ProjectResolver.addDependencies( p.getAllDependencies(), model.parentDependencies, inheritedScope, excluded );
ProjectResolver.addDependencies( p.getAllDependencies(), model.getParentDependencies(), inheritedScope, excluded );
ProjectResolver.addDependencies( p.getManagedDependencies(), model.managedDependencies, inheritedScope, Collections.EMPTY_SET );
ProjectResolver.addDependencies( p.getManagedDependenciesCollection(), model.getManagedDependencies(), inheritedScope, Collections.EMPTY_SET );
model.getRepositories().addAll( p.getRepositories() );
@ -239,7 +242,7 @@ public class ModelReader
if ( insideDependencyManagement )
{
model.managedDependencies.put( currentDependency.getConflictId(), currentDependency );
model.getManagedDependencies().put( currentDependency.getConflictId(), currentDependency );
}
else
{
@ -255,6 +258,10 @@ public class ModelReader
{
insideDependencyManagement = false;
}
else if ( rawName.equals( "distributionManagement" ) )
{
insideDistributionManagement = false;
}
else if ( rawName.equals( "resource" ) )
{
model.getResources().add( currentResource );
@ -263,7 +270,10 @@ public class ModelReader
}
else if ( rawName.equals( "repository" ) )
{
model.getRepositories().add( currentRepository );
if ( !insideDistributionManagement )
{
model.getRepositories().add( currentRepository );
}
insideRepository = false;
}

View File

@ -59,7 +59,7 @@ public final class ProjectResolver
{
if ( dependency.getVersion() == null )
{
Dependency managedDependency = (Dependency) model.managedDependencies.get( dependency
Dependency managedDependency = (Dependency) model.getManagedDependencies().get( dependency
.getConflictId() );
if ( managedDependency == null )
@ -80,7 +80,7 @@ public final class ProjectResolver
dependency.getVersion(), dependency.getScope(),
resolveTransitiveDependencies, excluded2, dependency.getChain() );
addDependencies( p.getAllDependencies(), model.transitiveDependencies, dependency.getScope(),
addDependencies( p.getAllDependencies(), model.getTransitiveDependencies(), dependency.getScope(),
excluded2 );
}
}