}
private void mergeManagedDependencies(Model model, ArtifactRepository localRepository, List parentSearchRepositories)
throws ProjectBuildingException
{
DependencyManagement modelDepMgmt = model.getDependencyManagement();
if (modelDepMgmt != null)
{
Map depsMap = new TreeMap();
Iterator iter = modelDepMgmt.getDependencies().iterator();
boolean doInclude = false;
while (iter.hasNext())
{
Dependency dep = (Dependency) iter.next();
depsMap.put( dep.getManagementKey(), dep );
if ( dep.getType().equals( "pom" ) && Artifact.SCOPE_IMPORT.equals( dep.getScope() ) )
{
doInclude = true;
}
}
Map newDeps = new TreeMap(depsMap);
iter = modelDepMgmt.getDependencies().iterator();
if (doInclude)
{
while (iter.hasNext())
{
Dependency dep = (Dependency)iter.next();
if ( dep.getType().equals( "pom" )
&& Artifact.SCOPE_IMPORT.equals( dep.getScope() ) )
{
Artifact artifact = artifactFactory.createProjectArtifact( dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getScope() );
MavenProject project = buildFromRepository(artifact, parentSearchRepositories, localRepository, false);
DependencyManagement depMgmt = project.getDependencyManagement();
if (depMgmt != null)
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Importing managed dependencies for " + dep.toString() );
}
for ( Iterator it = depMgmt.getDependencies().iterator(); it.hasNext(); )
{
Dependency includedDep = (Dependency) it.next();
String key = includedDep.getManagementKey();
if (!newDeps.containsKey(key))
{