Search in sources :

Example 11 with StyledTextOutput

use of org.gradle.internal.logging.text.StyledTextOutput in project gradle by gradle.

the class ModelNodeRenderer method render.

@Override
public void render(ModelNode model, TextReportBuilder output) {
    if (model.isHidden() && !showHidden) {
        return;
    }
    StyledTextOutput styledTextoutput = output.getOutput();
    if (!model.getPath().equals(ModelPath.ROOT)) {
        printNodeName(model, styledTextoutput);
        maybePrintType(model, styledTextoutput);
        maybePrintValue(model, styledTextoutput);
        printCreator(model, styledTextoutput);
        maybePrintRules(model, styledTextoutput);
    }
    if (model instanceof ModelReferenceNode) {
        return;
    }
    Map<String, ModelNode> links = new TreeMap<String, ModelNode>();
    for (ModelNode node : model.getLinks(ModelType.untyped())) {
        links.put(node.getPath().getName(), node);
    }
    output.collection(links.values(), this);
}
Also used : ModelReferenceNode(org.gradle.model.internal.registry.ModelReferenceNode) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) TreeMap(java.util.TreeMap) ModelNode(org.gradle.model.internal.core.ModelNode)

Example 12 with StyledTextOutput

use of org.gradle.internal.logging.text.StyledTextOutput in project gradle by gradle.

the class ProjectReportTask method render.

private void render(final Project project, GraphRenderer renderer, boolean lastChild, final StyledTextOutput textOutput) {
    renderer.visit(new Action<StyledTextOutput>() {

        public void execute(StyledTextOutput styledTextOutput) {
            styledTextOutput.text(StringUtils.capitalize(project.toString()));
            if (GUtil.isTrue(project.getDescription())) {
                textOutput.withStyle(Description).format(" - %s", project.getDescription());
            }
        }
    }, lastChild);
    renderer.startChildren();
    List<Project> children = getChildren(project);
    for (Project child : children) {
        render(child, renderer, child == children.get(children.size() - 1), textOutput);
    }
    renderer.completeChildren();
}
Also used : Project(org.gradle.api.Project) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 13 with StyledTextOutput

use of org.gradle.internal.logging.text.StyledTextOutput in project gradle by gradle.

the class NativeDependentBinariesResolutionStrategy method onCircularDependencies.

private void onCircularDependencies(final State state, final Deque<NativeBinarySpecInternal> stack, NativeBinarySpecInternal target) {
    GraphNodeRenderer<NativeBinarySpecInternal> nodeRenderer = new GraphNodeRenderer<NativeBinarySpecInternal>() {

        @Override
        public void renderTo(NativeBinarySpecInternal node, StyledTextOutput output) {
            String name = DependentComponentsUtils.getBuildScopedTerseName(node.getId());
            output.withStyle(StyledTextOutput.Style.Identifier).text(name);
        }
    };
    DirectedGraph<NativeBinarySpecInternal, Object> directedGraph = new DirectedGraph<NativeBinarySpecInternal, Object>() {

        @Override
        public void getNodeValues(NativeBinarySpecInternal node, Collection<? super Object> values, Collection<? super NativeBinarySpecInternal> connectedNodes) {
            for (NativeBinarySpecInternal binary : stack) {
                if (state.getDependents(node).contains(binary)) {
                    connectedNodes.add(binary);
                }
            }
        }
    };
    DirectedGraphRenderer<NativeBinarySpecInternal> graphRenderer = new DirectedGraphRenderer<NativeBinarySpecInternal>(nodeRenderer, directedGraph);
    StringWriter writer = new StringWriter();
    graphRenderer.renderTo(target, writer);
    throw new CircularReferenceException(String.format("Circular dependency between the following binaries:%n%s", writer.toString()));
}
Also used : StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) CircularReferenceException(org.gradle.api.CircularReferenceException) DirectedGraph(org.gradle.internal.graph.DirectedGraph) StringWriter(java.io.StringWriter) DirectedGraphRenderer(org.gradle.internal.graph.DirectedGraphRenderer) Collection(java.util.Collection) GraphNodeRenderer(org.gradle.internal.graph.GraphNodeRenderer)

Example 14 with StyledTextOutput

use of org.gradle.internal.logging.text.StyledTextOutput in project gradle by gradle.

the class BuildExceptionReporter method renderSingleBuildException.

private void renderSingleBuildException(Throwable failure) {
    StyledTextOutput output = textOutputFactory.create(BuildExceptionReporter.class, LogLevel.ERROR);
    FailureDetails details = constructFailureDetails("Build", failure);
    output.println();
    output.withStyle(Failure).text("FAILURE: ");
    details.summary.writeTo(output.withStyle(Failure));
    output.println();
    writeFailureDetails(output, details);
}
Also used : StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) BufferingStyledTextOutput(org.gradle.internal.logging.text.BufferingStyledTextOutput) LinePrefixingStyledTextOutput(org.gradle.internal.logging.text.LinePrefixingStyledTextOutput)

Example 15 with StyledTextOutput

use of org.gradle.internal.logging.text.StyledTextOutput in project gradle by gradle.

the class BuildExceptionReporter method renderMultipleBuildExceptions.

private void renderMultipleBuildExceptions(MultipleBuildFailures multipleFailures) {
    List<? extends Throwable> causes = multipleFailures.getCauses();
    StyledTextOutput output = textOutputFactory.create(BuildExceptionReporter.class, LogLevel.ERROR);
    output.println();
    output.withStyle(Failure).format("FAILURE: Build completed with %s failures.", causes.size());
    output.println();
    for (int i = 0; i < causes.size(); i++) {
        Throwable cause = causes.get(i);
        FailureDetails details = constructFailureDetails("Task", cause);
        output.println();
        output.withStyle(Failure).format("%s: ", i + 1);
        details.summary.writeTo(output.withStyle(Failure));
        output.println();
        output.text("-----------");
        writeFailureDetails(output, details);
        output.println("==============================================================================");
    }
}
Also used : StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) BufferingStyledTextOutput(org.gradle.internal.logging.text.BufferingStyledTextOutput) LinePrefixingStyledTextOutput(org.gradle.internal.logging.text.LinePrefixingStyledTextOutput)

Aggregations

StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)24 Project (org.gradle.api.Project)6 TaskAction (org.gradle.api.tasks.TaskAction)5 BuildClientMetaData (org.gradle.initialization.BuildClientMetaData)5 LinePrefixingStyledTextOutput (org.gradle.internal.logging.text.LinePrefixingStyledTextOutput)5 GraphRenderer (org.gradle.internal.graph.GraphRenderer)4 StringWriter (java.io.StringWriter)2 DependencyGraphRenderer (org.gradle.api.tasks.diagnostics.internal.graph.DependencyGraphRenderer)2 NodeRenderer (org.gradle.api.tasks.diagnostics.internal.graph.NodeRenderer)2 DirectedGraphRenderer (org.gradle.internal.graph.DirectedGraphRenderer)2 BufferingStyledTextOutput (org.gradle.internal.logging.text.BufferingStyledTextOutput)2 ModelNode (org.gradle.model.internal.core.ModelNode)2 ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)2 ComponentSpec (org.gradle.platform.base.ComponentSpec)2 Expectations (org.jmock.Expectations)2 Sequence (org.jmock.Sequence)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1