Search in sources :

Example 11 with DependencyNode

use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-dependency-plugin by apache.

the class TestTreeMojo method assertChildNodeEquals.

// private methods --------------------------------------------------------
private void assertChildNodeEquals(String expectedNode, DependencyNode actualParentNode, int actualChildIndex) {
    DependencyNode actualNode = actualParentNode.getChildren().get(actualChildIndex);
    assertNodeEquals(expectedNode, actualNode);
}
Also used : DependencyNode(org.apache.maven.shared.dependency.graph.DependencyNode)

Example 12 with DependencyNode

use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-dependency-plugin by apache.

the class TestTreeMojo method _testTreeTestEnvironment.

/**
 * Tests the proper discovery and configuration of the mojo.
 *
 * @throws Exception in case of an error.
 */
public void _testTreeTestEnvironment() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml");
    TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom);
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    MavenProject project = mojo.getProject();
    project.setArtifact(this.stubFactory.createArtifact("testGroupId", "project", "1.0"));
    Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
    Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
    artifacts.addAll(directArtifacts);
    project.setArtifacts(artifacts);
    project.setDependencyArtifacts(directArtifacts);
    mojo.execute();
    DependencyNode rootNode = mojo.getDependencyGraph();
    assertNodeEquals("testGroupId:project:jar:1.0:compile", rootNode);
    assertEquals(2, rootNode.getChildren().size());
    assertChildNodeEquals("testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 0);
    assertChildNodeEquals("testGroupId:release:jar:1.0:compile", rootNode, 1);
}
Also used : TreeMojo(org.apache.maven.plugins.dependency.tree.TreeMojo) MavenProject(org.apache.maven.project.MavenProject) DependencyNode(org.apache.maven.shared.dependency.graph.DependencyNode) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 13 with DependencyNode

use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-dependency-plugin by apache.

the class TGFDependencyNodeVisitor method endVisit.

/**
 * {@inheritDoc}
 */
@Override
public boolean endVisit(DependencyNode node) {
    if (node.getParent() == null || node.getParent() == node) {
        // dump edges on last node endVisit
        writer.println("#");
        for (EdgeAppender edge : edges) {
            writer.println(edge.toString());
        }
    } else {
        DependencyNode p = node.getParent();
        // using scope as edge label.
        edges.add(new EdgeAppender(p, node, node.getArtifact().getScope()));
    }
    return true;
}
Also used : DependencyNode(org.apache.maven.shared.dependency.graph.DependencyNode)

Example 14 with DependencyNode

use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-dependency-plugin by apache.

the class GraphmlDependencyNodeVisitor method endVisit.

/**
 * {@inheritDoc}
 */
@Override
public boolean endVisit(DependencyNode node) {
    if (node.getParent() == null || node.getParent() == node) {
        writer.write(GRAPHML_FOOTER);
    } else {
        DependencyNode p = node.getParent();
        writer.print("<edge source=\"" + generateId(p) + "\" target=\"" + generateId(node) + "\">");
        if (node.getArtifact().getScope() != null) {
            // add Edge label
            writer.print("<data key=\"d1\"><y:PolyLineEdge><y:EdgeLabel>" + node.getArtifact().getScope() + "</y:EdgeLabel></y:PolyLineEdge></data>");
        }
        writer.println("</edge>");
    }
    return true;
}
Also used : DependencyNode(org.apache.maven.shared.dependency.graph.DependencyNode)

Example 15 with DependencyNode

use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-plugins by apache.

the class TGFDependencyNodeVisitor method endVisit.

/**
 * {@inheritDoc}
 */
@Override
public boolean endVisit(DependencyNode node) {
    if (node.getParent() == null || node.getParent() == node) {
        // dump edges on last node endVisit
        writer.println("#");
        for (EdgeAppender edge : edges) {
            writer.println(edge.toString());
        }
    } else {
        DependencyNode p = node.getParent();
        // using scope as edge label.
        edges.add(new EdgeAppender(p, node, node.getArtifact().getScope()));
    }
    return true;
}
Also used : DependencyNode(org.apache.maven.shared.dependency.graph.DependencyNode)

Aggregations

DependencyNode (org.apache.maven.shared.dependency.graph.DependencyNode)23 MavenProject (org.apache.maven.project.MavenProject)9 Artifact (org.apache.maven.artifact.Artifact)8 DependencyGraphBuilder (org.apache.maven.shared.dependency.graph.DependencyGraphBuilder)8 Builder (aQute.bnd.osgi.Builder)7 HashMap (java.util.HashMap)7 Properties (java.util.Properties)7 LinkedHashSet (java.util.LinkedHashSet)6 Map (java.util.Map)6 Manifest (java.util.jar.Manifest)6 File (java.io.File)5 Set (java.util.Set)5 TreeMap (java.util.TreeMap)5 ArrayList (java.util.ArrayList)4 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)3 IOException (java.io.IOException)2 List (java.util.List)2 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)2 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)2 AndArtifactFilter (org.apache.maven.artifact.resolver.filter.AndArtifactFilter)2