mirror of https://github.com/apache/maven.git
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:
parent
c7c6b5d7c7
commit
74369ff5a3
|
@ -33,12 +33,6 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class Model
|
public class Model
|
||||||
{
|
{
|
||||||
private Map dependencies = new HashMap();
|
|
||||||
|
|
||||||
Map parentDependencies = new HashMap();
|
|
||||||
|
|
||||||
Map transitiveDependencies = new HashMap();
|
|
||||||
|
|
||||||
private Map plugins = new HashMap();
|
private Map plugins = new HashMap();
|
||||||
|
|
||||||
private String artifactId;
|
private String artifactId;
|
||||||
|
@ -63,7 +57,13 @@ public class Model
|
||||||
|
|
||||||
private Set repositories = new HashSet();
|
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;
|
private List chain;
|
||||||
|
|
||||||
|
@ -183,13 +183,6 @@ public class Model
|
||||||
return repositories;
|
return repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection getManagedDependencies()
|
|
||||||
{
|
|
||||||
Map m = new HashMap();
|
|
||||||
m.putAll( managedDependencies );
|
|
||||||
return m.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection getAllDependencies()
|
public Collection getAllDependencies()
|
||||||
{
|
{
|
||||||
Map m = new HashMap();
|
Map m = new HashMap();
|
||||||
|
@ -209,6 +202,28 @@ public class Model
|
||||||
return dependencies;
|
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()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "Model[" + getId() + "]";
|
return "Model[" + getId() + "]";
|
||||||
|
|
|
@ -45,13 +45,13 @@ public class ModelReader
|
||||||
|
|
||||||
private Resource currentResource;
|
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();
|
private StringBuffer bodyText = new StringBuffer();
|
||||||
|
|
||||||
|
@ -61,7 +61,9 @@ public class ModelReader
|
||||||
|
|
||||||
private final ArtifactResolver resolver;
|
private final ArtifactResolver resolver;
|
||||||
|
|
||||||
private boolean insideDependencyManagement = false;
|
private boolean insideDependencyManagement;
|
||||||
|
|
||||||
|
private boolean insideDistributionManagement;
|
||||||
|
|
||||||
private boolean insideReleases;
|
private boolean insideReleases;
|
||||||
|
|
||||||
|
@ -125,8 +127,6 @@ public class ModelReader
|
||||||
}
|
}
|
||||||
else if ( rawName.equals( "dependency" ) )
|
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() );
|
currentDependency = new Dependency( model.getChain() );
|
||||||
|
|
||||||
insideDependency = true;
|
insideDependency = true;
|
||||||
|
@ -145,6 +145,10 @@ public class ModelReader
|
||||||
{
|
{
|
||||||
insideDependencyManagement = true;
|
insideDependencyManagement = true;
|
||||||
}
|
}
|
||||||
|
else if ( rawName.equals( "distributionManagement" ) )
|
||||||
|
{
|
||||||
|
insideDistributionManagement = true;
|
||||||
|
}
|
||||||
else if ( rawName.equals( "resource" ) )
|
else if ( rawName.equals( "resource" ) )
|
||||||
{
|
{
|
||||||
currentResource = new Resource();
|
currentResource = new Resource();
|
||||||
|
@ -219,13 +223,12 @@ public class ModelReader
|
||||||
model.setVersion( model.getParentVersion() );
|
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 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() );
|
model.getRepositories().addAll( p.getRepositories() );
|
||||||
|
|
||||||
|
@ -239,7 +242,7 @@ public class ModelReader
|
||||||
|
|
||||||
if ( insideDependencyManagement )
|
if ( insideDependencyManagement )
|
||||||
{
|
{
|
||||||
model.managedDependencies.put( currentDependency.getConflictId(), currentDependency );
|
model.getManagedDependencies().put( currentDependency.getConflictId(), currentDependency );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -255,6 +258,10 @@ public class ModelReader
|
||||||
{
|
{
|
||||||
insideDependencyManagement = false;
|
insideDependencyManagement = false;
|
||||||
}
|
}
|
||||||
|
else if ( rawName.equals( "distributionManagement" ) )
|
||||||
|
{
|
||||||
|
insideDistributionManagement = false;
|
||||||
|
}
|
||||||
else if ( rawName.equals( "resource" ) )
|
else if ( rawName.equals( "resource" ) )
|
||||||
{
|
{
|
||||||
model.getResources().add( currentResource );
|
model.getResources().add( currentResource );
|
||||||
|
@ -262,8 +269,11 @@ public class ModelReader
|
||||||
insideResource = false;
|
insideResource = false;
|
||||||
}
|
}
|
||||||
else if ( rawName.equals( "repository" ) )
|
else if ( rawName.equals( "repository" ) )
|
||||||
|
{
|
||||||
|
if ( !insideDistributionManagement )
|
||||||
{
|
{
|
||||||
model.getRepositories().add( currentRepository );
|
model.getRepositories().add( currentRepository );
|
||||||
|
}
|
||||||
|
|
||||||
insideRepository = false;
|
insideRepository = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public final class ProjectResolver
|
||||||
{
|
{
|
||||||
if ( dependency.getVersion() == null )
|
if ( dependency.getVersion() == null )
|
||||||
{
|
{
|
||||||
Dependency managedDependency = (Dependency) model.managedDependencies.get( dependency
|
Dependency managedDependency = (Dependency) model.getManagedDependencies().get( dependency
|
||||||
.getConflictId() );
|
.getConflictId() );
|
||||||
|
|
||||||
if ( managedDependency == null )
|
if ( managedDependency == null )
|
||||||
|
@ -80,7 +80,7 @@ public final class ProjectResolver
|
||||||
dependency.getVersion(), dependency.getScope(),
|
dependency.getVersion(), dependency.getScope(),
|
||||||
resolveTransitiveDependencies, excluded2, dependency.getChain() );
|
resolveTransitiveDependencies, excluded2, dependency.getChain() );
|
||||||
|
|
||||||
addDependencies( p.getAllDependencies(), model.transitiveDependencies, dependency.getScope(),
|
addDependencies( p.getAllDependencies(), model.getTransitiveDependencies(), dependency.getScope(),
|
||||||
excluded2 );
|
excluded2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue