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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations