}
private void computeDependencyTree(final Project project, final SensorContext context) {
LOG.warn("Computation of Maven dependencies by SonarQube is deprecated. Please update the version of SonarQube Maven plugin to 2.5+");
try {
DependencyNode root = treeBuilder.buildDependencyTree(project.getPom(), localRepository, artifactFactory, artifactMetadataSource, null, artifactCollector);
DependencyNodeVisitor visitor = new BuildingDependencyNodeVisitor(new DependencyNodeVisitor() {
@Override
public boolean visit(DependencyNode node) {
return true;
}
@Override
public boolean endVisit(DependencyNode node) {
if (node.getParent() != null && node.getParent() != node) {
saveDependency(project, node, context);
}
return true;
}
});
// mode verbose OFF : do not show the same lib many times
DependencyNodeFilter filter = StateDependencyNodeFilter.INCLUDED;
CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor(collectingVisitor, filter);
root.accept(firstPassVisitor);
DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter(collectingVisitor.getNodes());
visitor = new FilteringDependencyNodeVisitor(visitor, secondPassFilter);
root.accept(visitor);
} catch (DependencyTreeBuilderException e) {
throw new SonarException("Can not load the graph of dependencies of the project " + project.getKey(), e);
}
}