}
public boolean updateExcludesInDeps( MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps )
throws DependencyTreeBuilderException
{
DependencyNode node = dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
artifactMetadataSource, null,
artifactCollector );
boolean modified = false;
Iterator it = node.getChildren().listIterator();
while ( it.hasNext() )
{
DependencyNode n2 = (DependencyNode) it.next();
Iterator it2 = n2.getChildren().listIterator();
while ( it2.hasNext() )
{
DependencyNode n3 = (DependencyNode) it2.next();
//anything two levels deep that is marked "included"
//is stuff that was excluded by the original poms, make sure it
//remains excluded IF promoting transitives.
if ( n3.getState() == DependencyNode.INCLUDED )
{
//check if it really isn't in the list of original dependencies. Maven
//prior to 2.0.8 may grab versions from transients instead of
//from the direct deps in which case they would be marked included
//instead of OMITTED_FOR_DUPLICATE
//also, if not promoting the transitives, level 2's would be included
boolean found = false;
for ( int x = 0; x < transitiveDeps.size(); x++ )
{
Dependency dep = transitiveDeps.get( x );
if ( dep.getArtifactId().equals( n3.getArtifact().getArtifactId() ) && dep.getGroupId().equals(
n3.getArtifact().getGroupId() ) )
{
found = true;
}
}
if ( !found )
{
for ( int x = 0; x < dependencies.size(); x++ )
{
Dependency dep = dependencies.get( x );
if ( dep.getArtifactId().equals( n2.getArtifact().getArtifactId() )
&& dep.getGroupId().equals( n2.getArtifact().getGroupId() ) )
{
Exclusion exclusion = new Exclusion();
exclusion.setArtifactId( n3.getArtifact().getArtifactId() );
exclusion.setGroupId( n3.getArtifact().getGroupId() );
dep.addExclusion( exclusion );
modified = true;
break;
}
}