use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-plugins 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 Dependencies method addAllChildrenDependencies.
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
/**
* Recursive method to get all dependencies from a given <code>dependencyNode</code>
*
* @param dependencyNode not null
*/
private void addAllChildrenDependencies(DependencyNode dependencyNode) {
for (DependencyNode subdependencyNode : dependencyNode.getChildren()) {
Artifact artifact = subdependencyNode.getArtifact();
if (artifact.getGroupId().equals(project.getGroupId()) && artifact.getArtifactId().equals(project.getArtifactId()) && artifact.getVersion().equals(project.getVersion())) {
continue;
}
if (!allDependencies.contains(artifact)) {
allDependencies.add(artifact);
}
addAllChildrenDependencies(subdependencyNode);
}
}
use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-plugins by apache.
the class DependenciesRenderer method printDependencyListing.
private void printDependencyListing(DependencyNode node) {
Artifact artifact = node.getArtifact();
String id = artifact.getId();
String dependencyDetailId = "_dep" + idCounter++;
String imgId = "_img" + idCounter++;
sink.listItem();
sink.text(id + (StringUtils.isNotEmpty(artifact.getScope()) ? " (" + artifact.getScope() + ") " : " "));
String javascript = String.format("<img id=\"%s\" src=\"%s\" alt=\"%s\"" + " onclick=\"toggleDependencyDetails( '%s', '%s' );\"" + " style=\"cursor: pointer; vertical-align: text-bottom;\"></img>", imgId, IMG_INFO_URL, getI18nString("graph.icon.information"), dependencyDetailId, imgId);
sink.rawText(javascript);
printDescriptionsAndURLs(node, dependencyDetailId);
if (!node.getChildren().isEmpty()) {
boolean toBeIncluded = false;
List<DependencyNode> subList = new ArrayList<DependencyNode>();
for (DependencyNode dep : node.getChildren()) {
if (dependencies.getAllDependencies().contains(dep.getArtifact())) {
subList.add(dep);
toBeIncluded = true;
}
}
if (toBeIncluded) {
sink.list();
for (DependencyNode dep : subList) {
printDependencyListing(dep);
}
sink.list_();
}
}
sink.listItem_();
}
use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-plugins by apache.
the class ShadeMojo method updateExcludesInDeps.
public boolean updateExcludesInDeps(MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps) throws DependencyGraphBuilderException {
DependencyNode node = dependencyGraphBuilder.buildDependencyGraph(project, null);
boolean modified = false;
for (DependencyNode n2 : node.getChildren()) {
for (DependencyNode n3 : n2.getChildren()) {
// check if it really isn't in the list of original dependencies. Maven
// prior to 2.0.8 may grab versions from transients instead of
// from the direct deps in which case they would be marked included
// instead of OMITTED_FOR_DUPLICATE
// also, if not promoting the transitives, level 2's would be included
boolean found = false;
for (Dependency dep : transitiveDeps) {
if (dep.getArtifactId().equals(n3.getArtifact().getArtifactId()) && dep.getGroupId().equals(n3.getArtifact().getGroupId()) && (dep.getType() == null || dep.getType().equals(n3.getArtifact().getType()))) {
found = true;
break;
}
}
if (!found) {
for (Dependency dep : dependencies) {
if (dep.getArtifactId().equals(n2.getArtifact().getArtifactId()) && dep.getGroupId().equals(n2.getArtifact().getGroupId()) && (dep.getType() == null || dep.getType().equals(n2.getArtifact().getType()))) {
Exclusion exclusion = new Exclusion();
exclusion.setArtifactId(n3.getArtifact().getArtifactId());
exclusion.setGroupId(n3.getArtifact().getGroupId());
dep.addExclusion(exclusion);
modified = true;
break;
}
}
}
}
}
return modified;
}
use of org.apache.maven.shared.dependency.graph.DependencyNode in project maven-plugins 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);
}
Aggregations