Search in sources :

Example 1 with CheckScalaVersionVisitor

use of scala_maven_dependency.CheckScalaVersionVisitor 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!");
    }
}
Also used : FilteringDependencyNodeVisitor(org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor) CollectingDependencyNodeVisitor(org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor) AncestorOrSelfDependencyNodeFilter(org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter) CheckScalaVersionVisitor(scala_maven_dependency.CheckScalaVersionVisitor) AncestorOrSelfDependencyNodeFilter(org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter) AndDependencyNodeFilter(org.apache.maven.shared.dependency.tree.filter.AndDependencyNodeFilter) DependencyNodeFilter(org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DependencyNodeVisitor(org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor) FilteringDependencyNodeVisitor(org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor) CollectingDependencyNodeVisitor(org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor)

Aggregations

MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 AncestorOrSelfDependencyNodeFilter (org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter)1 AndDependencyNodeFilter (org.apache.maven.shared.dependency.tree.filter.AndDependencyNodeFilter)1 DependencyNodeFilter (org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter)1 CollectingDependencyNodeVisitor (org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor)1 DependencyNodeVisitor (org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor)1 FilteringDependencyNodeVisitor (org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor)1 CheckScalaVersionVisitor (scala_maven_dependency.CheckScalaVersionVisitor)1