DependencyNode ( @NotNull ResolvedDependencyResult dependency, @NotNull Map<Object, DependencyNode> added, @NotNull IdGenerator idGenerator ) { ResolvedComponentResult resolvedComponent = dependency.getSelected(); ComponentIdentifier componentId = resolvedComponent.getId(); long id = idGenerator.getId(componentId); if (added.containsKey(id)) { return new ReferenceNode(id); } AbstractDependencyNode node; if (componentId instanceof ProjectComponentIdentifier) { ProjectComponentIdentifier projectId = (ProjectComponentIdentifier)componentId; String projectName = getProjectName(projectId); String projectPath = projectId.getProjectPath(); node = new ProjectDependencyNodeImpl(id, projectName, projectPath); } else if (componentId instanceof ModuleComponentIdentifier) { ModuleComponentIdentifier moduleId = (ModuleComponentIdentifier)componentId; node = new ArtifactDependencyNodeImpl(id, moduleId.getGroup(), moduleId.getModule(), moduleId.getVersion()); } else { node = new UnknownDependencyNode(id, componentId.getDisplayName()); } node.setResolutionState(ResolutionState.RESOLVED); ComponentSelectionReason selectionReason = resolvedComponent.getSelectionReason(); if (DefaultGroovyMethods.asBoolean(DefaultGroovyMethods.hasProperty(selectionReason, "descriptions"))) { List<ComponentSelectionDescriptor> descriptions = selectionReason.getDescriptions(); if (!descriptions.isEmpty()) { node.setSelectionReason(DefaultGroovyMethods.last(descriptions).getDescription()); } } added.put(id, node); for (DependencyResult child : resolvedComponent.getDependencies()) { node.getDependencies().add(buildDependencyNode(child, added, idGenerator)); } return node; }