use of org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor in project scala-maven-plugin by davidB.
the class ScalaMojoSupport method checkArtifactForScalaVersion.
/**
* Visits a node (and all dependencies) to see if it contains duplicate scala versions
*/
private void checkArtifactForScalaVersion(VersionNumber requiredScalaVersion, DependencyNode rootNode) throws Exception {
final CheckScalaVersionVisitor visitor = new CheckScalaVersionVisitor(requiredScalaVersion, getLog(), getScalaOrganization());
CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor(collectingVisitor, createScalaDistroDependencyFilter());
rootNode.accept(firstPassVisitor);
DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter(collectingVisitor.getNodes());
DependencyNodeVisitor filteredVisitor = new FilteringDependencyNodeVisitor(visitor, secondPassFilter);
rootNode.accept(filteredVisitor);
if (visitor.isFailed()) {
visitor.logScalaDependents();
if (failOnMultipleScalaVersions) {
getLog().error("Multiple versions of scala libraries detected!");
throw new MojoFailureException("Multiple versions of scala libraries detected!");
}
getLog().warn("Multiple versions of scala libraries detected!");
}
}
use of org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor in project maven-plugins by apache.
the class DependencyConvergenceReport method serializeDependencyTree.
/**
* Serializes the specified dependency tree to a string.
*
* @param rootNode the dependency tree root node to serialize
* @return the serialized dependency tree
*/
private void serializeDependencyTree(DependencyNode rootNode, String key, Sink sink) {
DependencyNodeVisitor visitor = getSerializingDependencyNodeVisitor(sink);
visitor = new BuildingDependencyNodeVisitor(visitor);
DependencyNodeFilter filter = createDependencyNodeFilter(key);
if (filter != null) {
CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor(collectingVisitor, filter);
rootNode.accept(firstPassVisitor);
DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter(collectingVisitor.getNodes());
visitor = new FilteringDependencyNodeVisitor(visitor, secondPassFilter);
}
rootNode.accept(visitor);
}
Aggregations