Search in sources :

Example 6 with RenderableDependency

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

the class DependencyGraphRenderer method renderChildren.

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

Example 7 with RenderableDependency

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

the class AsciiDependencyReportRenderer method render.

@Override
public void render(Configuration configuration) throws IOException {
    if (configuration.isCanBeResolved()) {
        ResolutionResult result = configuration.getIncoming().getResolutionResult();
        RenderableDependency root = new RenderableModuleResult(result.getRoot());
        renderNow(root);
    } else {
        renderNow(new UnresolvableConfigurationResult(configuration));
    }
}
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 8 with RenderableDependency

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

the class DependencyInsightReportTask method report.

@TaskAction
public void report() {
    final Configuration configuration = getConfiguration();
    if (configuration == null) {
        throw new InvalidUserDataException("Dependency insight report cannot be generated because the input configuration was not specified. " + "\nIt can be specified from the command line, e.g: '" + getPath() + " --configuration someConf --dependency someDep'");
    }
    if (dependencySpec == null) {
        throw new InvalidUserDataException("Dependency insight report cannot be generated because the dependency to show was not specified." + "\nIt can be specified from the command line, e.g: '" + getPath() + " --dependency someDep'");
    }
    StyledTextOutput output = getTextOutputFactory().create(getClass());
    final GraphRenderer renderer = new GraphRenderer(output);
    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    final Set<DependencyResult> selectedDependencies = new LinkedHashSet<DependencyResult>();
    result.allDependencies(new Action<DependencyResult>() {

        @Override
        public void execute(DependencyResult dependencyResult) {
            if (dependencySpec.isSatisfiedBy(dependencyResult)) {
                selectedDependencies.add(dependencyResult);
            }
        }
    });
    if (selectedDependencies.isEmpty()) {
        output.println("No dependencies matching given input were found in " + String.valueOf(configuration));
        return;
    }
    Collection<RenderableDependency> sortedDeps = new DependencyInsightReporter().prepare(selectedDependencies, getVersionSelectorScheme(), getVersionComparator());
    NodeRenderer nodeRenderer = new NodeRenderer() {

        public void renderNode(StyledTextOutput target, RenderableDependency node, boolean alreadyRendered) {
            boolean leaf = node.getChildren().isEmpty();
            target.text(leaf ? configuration.getName() : node.getName());
            if (alreadyRendered && !leaf) {
                target.withStyle(Info).text(" (*)");
            }
        }
    };
    LegendRenderer legendRenderer = new LegendRenderer(output);
    DependencyGraphRenderer dependencyGraphRenderer = new DependencyGraphRenderer(renderer, nodeRenderer, legendRenderer);
    int i = 1;
    for (final RenderableDependency dependency : sortedDeps) {
        renderer.visit(new RenderDependencyAction(dependency, configuration), true);
        dependencyGraphRenderer.render(dependency);
        boolean last = i++ == sortedDeps.size();
        if (!last) {
            output.println();
        }
    }
    legendRenderer.printLegend();
    output.println();
    output.text("A web-based, searchable dependency report is available by adding the ");
    output.withStyle(UserInput).format("--%s", StartParameterBuildOptions.BuildScanOption.LONG_OPTION);
    output.println(" option.");
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) Configuration(org.gradle.api.artifacts.Configuration) DependencyResult(org.gradle.api.artifacts.result.DependencyResult) ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) DependencyGraphRenderer(org.gradle.api.tasks.diagnostics.internal.graph.DependencyGraphRenderer) NodeRenderer(org.gradle.api.tasks.diagnostics.internal.graph.NodeRenderer) DependencyInsightReporter(org.gradle.api.tasks.diagnostics.internal.insight.DependencyInsightReporter) LegendRenderer(org.gradle.api.tasks.diagnostics.internal.graph.LegendRenderer) GraphRenderer(org.gradle.internal.graph.GraphRenderer) DependencyGraphRenderer(org.gradle.api.tasks.diagnostics.internal.graph.DependencyGraphRenderer) InvalidUserDataException(org.gradle.api.InvalidUserDataException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 9 with RenderableDependency

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

the class DependencyInsightReporter method prepare.

public Collection<RenderableDependency> prepare(Collection<DependencyResult> input, VersionSelectorScheme versionSelectorScheme, VersionComparator versionComparator) {
    LinkedList<RenderableDependency> out = new LinkedList<RenderableDependency>();
    List<DependencyEdge> dependencies = CollectionUtils.collect(input, new Transformer<DependencyEdge, DependencyResult>() {

        @Override
        public DependencyEdge transform(DependencyResult result) {
            if (result instanceof UnresolvedDependencyResult) {
                return new UnresolvedDependencyEdge((UnresolvedDependencyResult) result);
            } else {
                return new ResolvedDependencyEdge((ResolvedDependencyResult) result);
            }
        }
    });
    Collection<DependencyEdge> sorted = DependencyResultSorter.sort(dependencies, versionSelectorScheme, versionComparator);
    // remember if module id was annotated
    HashSet<ComponentIdentifier> annotated = new HashSet<ComponentIdentifier>();
    RequestedVersion current = null;
    for (DependencyEdge dependency : sorted) {
        ResolvedVariantResult selectedVariant = dependency.getSelectedVariant();
        // add description only to the first module
        if (annotated.add(dependency.getActual())) {
            // add a heading dependency with the annotation if the dependency does not exist in the graph
            if (!dependency.getRequested().matchesStrictly(dependency.getActual())) {
                out.add(new DependencyReportHeader(dependency, selectedVariant));
                current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null, selectedVariant);
                out.add(current);
            } else {
                current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), getReasonDescription(dependency.getReason()), selectedVariant);
                out.add(current);
            }
        } else if (!current.getRequested().equals(dependency.getRequested())) {
            current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null, selectedVariant);
            out.add(current);
        }
        current.addChild(dependency);
    }
    return out;
}
Also used : UnresolvedDependencyResult(org.gradle.api.artifacts.result.UnresolvedDependencyResult) RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) UnresolvedDependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvedDependencyEdge) RequestedVersion(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RequestedVersion) DependencyResult(org.gradle.api.artifacts.result.DependencyResult) ResolvedDependencyResult(org.gradle.api.artifacts.result.ResolvedDependencyResult) UnresolvedDependencyResult(org.gradle.api.artifacts.result.UnresolvedDependencyResult) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) LinkedList(java.util.LinkedList) ResolvedDependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.ResolvedDependencyEdge) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) DependencyReportHeader(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader) DependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyEdge) ResolvedDependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.ResolvedDependencyEdge) UnresolvedDependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvedDependencyEdge) ResolvedDependencyResult(org.gradle.api.artifacts.result.ResolvedDependencyResult) HashSet(java.util.HashSet)

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