Search in sources :

Example 1 with RenderableDependency

use of org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency in project gradle by gradle.

the class JsonProjectDependencyRenderer method createDependencies.

private List createDependencies(Configuration configuration) {
    if (configuration.isCanBeResolved()) {
        ResolutionResult result = configuration.getIncoming().getResolutionResult();
        RenderableDependency root = new RenderableModuleResult(result.getRoot());
        return createDependencyChildren(root, new HashSet<Object>());
    } else {
        return createDependencyChildren(new UnresolvableConfigurationResult(configuration), new HashSet<Object>());
    }
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) UnresolvableConfigurationResult(org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvableConfigurationResult) ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) RenderableModuleResult(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableModuleResult)

Example 2 with RenderableDependency

use of org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency in project gradle by gradle.

the class JsonProjectDependencyRenderer method collectModules.

private Set<ModuleIdentifier> collectModules(Configuration configuration) {
    RenderableDependency root;
    if (configuration.isCanBeResolved()) {
        ResolutionResult result = configuration.getIncoming().getResolutionResult();
        root = new RenderableModuleResult(result.getRoot());
    } else {
        root = new UnresolvableConfigurationResult(configuration);
    }
    Set<ModuleIdentifier> modules = Sets.newHashSet();
    Set<ComponentIdentifier> visited = Sets.newHashSet();
    populateModulesWithChildDependencies(root, visited, modules);
    return modules;
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) UnresolvableConfigurationResult(org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvableConfigurationResult) ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier) RenderableModuleResult(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableModuleResult)

Example 3 with RenderableDependency

use of org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency in project gradle by gradle.

the class JsonProjectDependencyRenderer method createInsight.

private List createInsight(ModuleIdentifier module, final Configuration configuration) {
    final Spec<DependencyResult> dependencySpec = new StrictDependencyResultSpec(module);
    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    final Set<DependencyResult> selectedDependencies = new LinkedHashSet<DependencyResult>();
    result.allDependencies(new Action<DependencyResult>() {

        @Override
        public void execute(DependencyResult it) {
            if (dependencySpec.isSatisfiedBy(it)) {
                selectedDependencies.add(it);
            }
        }
    });
    Collection<RenderableDependency> sortedDeps = new DependencyInsightReporter().prepare(selectedDependencies, versionSelectorScheme, versionComparator);
    return CollectionUtils.collect(sortedDeps, new Transformer<Object, RenderableDependency>() {

        @Override
        public Object transform(RenderableDependency dependency) {
            String name = replaceArrow(dependency.getName());
            LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(5);
            map.put("name", replaceArrow(dependency.getName()));
            map.put("description", dependency.getDescription());
            map.put("resolvable", dependency.getResolutionState());
            map.put("hasConflict", !name.equals(dependency.getName()));
            map.put("children", createInsightDependencyChildren(dependency, new HashSet<Object>(), configuration));
            return map;
        }
    });
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) DependencyResult(org.gradle.api.artifacts.result.DependencyResult) ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) LinkedHashMap(java.util.LinkedHashMap) DependencyInsightReporter(org.gradle.api.tasks.diagnostics.internal.insight.DependencyInsightReporter)

Example 4 with RenderableDependency

use of org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency in project gradle by gradle.

the class DependentComponentsGraphRenderer method renderChildren.

private void renderChildren(Set<? extends RenderableDependency> children) {
    renderer.startChildren();
    int idx = 0;
    for (RenderableDependency child : children) {
        boolean last = idx++ == children.size() - 1;
        doRender(child, last);
    }
    renderer.completeChildren();
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency)

Example 5 with RenderableDependency

use of org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency in project gradle by gradle.

the class JsonProjectDependencyRenderer method populateModulesWithChildDependencies.

private void populateModulesWithChildDependencies(RenderableDependency dependency, Set<ComponentIdentifier> visited, Set<ModuleIdentifier> modules) {
    for (RenderableDependency childDependency : dependency.getChildren()) {
        ModuleIdentifier moduleId = getModuleIdentifier(childDependency);
        if (moduleId == null) {
            continue;
        }
        modules.add(moduleId);
        boolean alreadyVisited = !visited.add((ComponentIdentifier) childDependency.getId());
        if (!alreadyVisited) {
            populateModulesWithChildDependencies(childDependency, visited, modules);
        }
    }
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier)

Aggregations

RenderableDependency (org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency)9 ResolutionResult (org.gradle.api.artifacts.result.ResolutionResult)5 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)3 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)3 RenderableModuleResult (org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableModuleResult)3 UnresolvableConfigurationResult (org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvableConfigurationResult)3 LinkedHashSet (java.util.LinkedHashSet)2 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)2 DefaultModuleIdentifier (org.gradle.api.internal.artifacts.DefaultModuleIdentifier)2 DependencyInsightReporter (org.gradle.api.tasks.diagnostics.internal.insight.DependencyInsightReporter)2 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 Configuration (org.gradle.api.artifacts.Configuration)1 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)1 ResolvedVariantResult (org.gradle.api.artifacts.result.ResolvedVariantResult)1 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)1 TaskAction (org.gradle.api.tasks.TaskAction)1