Search in sources :

Example 16 with StyledTextOutput

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

the class BuildResultLogger method buildFinished.

public void buildFinished(BuildResult result) {
    StyledTextOutput textOutput = textOutputFactory.create(BuildResultLogger.class, LogLevel.LIFECYCLE);
    textOutput.println();
    String action = result.getAction().toUpperCase();
    if (result.getFailure() == null) {
        textOutput.withStyle(Success).text(action + " SUCCESSFUL");
    } else {
        textOutput.withStyle(Failure).text(action + " FAILED");
    }
    textOutput.println();
    textOutput.println();
    textOutput.formatln("Total time: %s", buildTimeClock.getElapsed());
}
Also used : StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 17 with StyledTextOutput

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

the class DependentComponentsRenderer method render.

@Override
public void render(final ComponentSpec component, final TextReportBuilder builder) {
    ComponentSpecInternal internalProtocol = (ComponentSpecInternal) component;
    DependentComponentsRenderableDependency root = getRenderableDependencyOf(component, internalProtocol);
    if (!showNonBuildable && !root.isBuildable()) {
        hiddenNonBuildable = true;
        return;
    }
    StyledTextOutput output = builder.getOutput();
    GraphRenderer renderer = new GraphRenderer(output);
    renderer.visit(new Action<StyledTextOutput>() {

        @Override
        public void execute(StyledTextOutput output) {
            output.withStyle(Identifier).text(component.getName());
            output.withStyle(Description).text(" - Components that depend on " + component.getDisplayName());
        }
    }, true);
    DependentComponentsGraphRenderer dependentsGraphRenderer = new DependentComponentsGraphRenderer(renderer, showNonBuildable, showTestSuites);
    if (root.getChildren().isEmpty()) {
        output.withStyle(Info).text("No dependents");
        output.println();
    } else {
        dependentsGraphRenderer.render(root);
        output.println();
    }
    if (dependentsGraphRenderer.hasSeenTestSuite()) {
        seenTestSuite = true;
    }
    if (dependentsGraphRenderer.hasHiddenTestSuite()) {
        hiddenTestSuite = true;
    }
    if (dependentsGraphRenderer.hasHiddenNonBuildable()) {
        hiddenNonBuildable = true;
    }
}
Also used : ComponentSpecInternal(org.gradle.platform.base.internal.ComponentSpecInternal) GraphRenderer(org.gradle.internal.graph.GraphRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 18 with StyledTextOutput

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

the class ModelReport method report.

@TaskAction
public void report() {
    Project project = getProject();
    StyledTextOutput textOutput = getTextOutputFactory().create(ModelReport.class);
    ModelNodeRenderer renderer = new ModelNodeRenderer(isShowHidden(), getFormat());
    TextModelReportRenderer textModelReportRenderer = new TextModelReportRenderer(renderer);
    textModelReportRenderer.setOutput(textOutput);
    textModelReportRenderer.startProject(project);
    ModelRegistry modelRegistry = getModelRegistry();
    ModelNode rootNode = modelRegistry.realizeNode(ModelPath.ROOT);
    // Ensure binding validation has been done. This should happen elsewhere
    modelRegistry.bindAllReferences();
    textModelReportRenderer.render(rootNode);
    textModelReportRenderer.completeProject(project);
    textModelReportRenderer.complete();
}
Also used : Project(org.gradle.api.Project) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) ModelNodeRenderer(org.gradle.api.reporting.model.internal.ModelNodeRenderer) TextModelReportRenderer(org.gradle.api.reporting.model.internal.TextModelReportRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ModelNode(org.gradle.model.internal.core.ModelNode) TaskAction(org.gradle.api.tasks.TaskAction)

Example 19 with StyledTextOutput

use of org.gradle.internal.logging.text.StyledTextOutput 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());
    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 Action<StyledTextOutput>() {

            public void execute(StyledTextOutput out) {
                out.withStyle(Identifier).text(dependency.getName());
                if (StringUtils.isNotEmpty(dependency.getDescription())) {
                    out.withStyle(Description).text(" (" + dependency.getDescription() + ")");
                }
                switch(dependency.getResolutionState()) {
                    case FAILED:
                        out.withStyle(Failure).text(" FAILED");
                        break;
                    case RESOLVED:
                        break;
                    case UNRESOLVED:
                        out.withStyle(Failure).text(" (n)");
                        break;
                }
            }
        }, true);
        dependencyGraphRenderer.render(dependency);
        boolean last = i++ == sortedDeps.size();
        if (!last) {
            output.println();
        }
    }
    legendRenderer.printLegend();
}
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 20 with StyledTextOutput

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

the class ProjectReportTask method generate.

@Override
protected void generate(Project project) throws IOException {
    BuildClientMetaData metaData = getClientMetaData();
    StyledTextOutput textOutput = getRenderer().getTextOutput();
    render(project, new GraphRenderer(textOutput), true, textOutput);
    if (project.getChildProjects().isEmpty()) {
        textOutput.withStyle(Info).text("No sub-projects");
        textOutput.println();
    }
    textOutput.println();
    textOutput.text("To see a list of the tasks of a project, run ");
    metaData.describeCommand(textOutput.withStyle(UserInput), "<project-path>:" + ProjectInternal.TASKS_TASK);
    textOutput.println();
    textOutput.text("For example, try running ");
    Project exampleProject = project.getChildProjects().isEmpty() ? project : getChildren(project).get(0);
    metaData.describeCommand(textOutput.withStyle(UserInput), exampleProject.absoluteProjectPath(ProjectInternal.TASKS_TASK));
    textOutput.println();
    if (project != project.getRootProject()) {
        textOutput.println();
        textOutput.text("To see a list of all the projects in this build, run ");
        metaData.describeCommand(textOutput.withStyle(UserInput), project.getRootProject().absoluteProjectPath(ProjectInternal.PROJECTS_TASK));
        textOutput.println();
    }
}
Also used : BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Project(org.gradle.api.Project) GraphRenderer(org.gradle.internal.graph.GraphRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

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