Search in sources :

Example 1 with DependencyReportHeader

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

the class DependencyInsightReporter method createHeaderForDependency.

private DependencyReportHeader createHeaderForDependency(DependencyEdge dependency, Set<Throwable> alreadyReportedErrors) {
    ComponentSelectionReasonInternal reason = (ComponentSelectionReasonInternal) dependency.getReason();
    Section selectionReasonsSection = buildSelectionReasonSection(reason);
    List<Section> reasonSections = selectionReasonsSection.getChildren();
    String reasonShortDescription;
    List<Section> extraDetails = Lists.newArrayList();
    boolean displayFullReasonSection = reason.hasCustomDescriptions() || reasonSections.size() > 1;
    if (displayFullReasonSection) {
        reasonShortDescription = null;
        extraDetails.add(selectionReasonsSection);
    } else {
        reasonShortDescription = reasonSections.isEmpty() ? null : reasonSections.get(0).getDescription().toLowerCase();
    }
    buildFailureSection(dependency, alreadyReportedErrors, extraDetails);
    List<ResolvedVariantResult> selectedVariants = dependency.getSelectedVariants();
    return new DependencyReportHeader(dependency, reasonShortDescription, selectedVariants, extraDetails);
}
Also used : ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) DependencyReportHeader(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader) DefaultSection(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection) Section(org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section) ComponentSelectionReasonInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)

Example 2 with DependencyReportHeader

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

the class DependencyInsightReporter method convertToRenderableItems.

public Collection<RenderableDependency> convertToRenderableItems(Collection<DependencyResult> dependencies, boolean singlePathToDependency) {
    LinkedList<RenderableDependency> out = new LinkedList<>();
    Collection<DependencyEdge> sortedEdges = toDependencyEdges(dependencies);
    // remember if module id was annotated
    Set<ComponentIdentifier> annotated = Sets.newHashSet();
    Set<Throwable> alreadyReportedErrors = Sets.newHashSet();
    RequestedVersion current = null;
    for (DependencyEdge dependency : sortedEdges) {
        // add description only to the first module
        if (annotated.add(dependency.getActual())) {
            DependencyReportHeader header = createHeaderForDependency(dependency, alreadyReportedErrors);
            out.add(header);
            current = newRequestedVersion(out, dependency);
        } else if (!current.getRequested().equals(dependency.getRequested())) {
            current = newRequestedVersion(out, dependency);
        }
        if (!singlePathToDependency || current.getChildren().isEmpty()) {
            current.addChild(dependency);
        }
    }
    return out;
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) RequestedVersion(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RequestedVersion) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) DependencyReportHeader(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader) ResolvedDependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.ResolvedDependencyEdge) DependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyEdge) UnresolvedDependencyEdge(org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvedDependencyEdge) LinkedList(java.util.LinkedList)

Example 3 with DependencyReportHeader

use of org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader 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

DependencyReportHeader (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader)3 LinkedList (java.util.LinkedList)2 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)2 ResolvedVariantResult (org.gradle.api.artifacts.result.ResolvedVariantResult)2 DependencyEdge (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyEdge)2 RenderableDependency (org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency)2 RequestedVersion (org.gradle.api.tasks.diagnostics.internal.graph.nodes.RequestedVersion)2 ResolvedDependencyEdge (org.gradle.api.tasks.diagnostics.internal.graph.nodes.ResolvedDependencyEdge)2 UnresolvedDependencyEdge (org.gradle.api.tasks.diagnostics.internal.graph.nodes.UnresolvedDependencyEdge)2 HashSet (java.util.HashSet)1 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)1 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)1 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)1 ComponentSelectionReasonInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)1 DefaultSection (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection)1 Section (org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section)1