Search in sources :

Example 1 with ConsoleDetector

use of org.gradle.internal.nativeintegration.console.ConsoleDetector in project gradle by gradle.

the class Pmd method stdOutIsAttachedToTerminal.

public boolean stdOutIsAttachedToTerminal() {
    ConsoleDetector consoleDetector = NativeServices.getInstance().get(ConsoleDetector.class);
    ConsoleMetaData consoleMetaData = consoleDetector.getConsole();
    return consoleMetaData != null && consoleMetaData.isStdOut();
}
Also used : ConsoleDetector(org.gradle.internal.nativeintegration.console.ConsoleDetector) ConsoleMetaData(org.gradle.internal.nativeintegration.console.ConsoleMetaData)

Example 2 with ConsoleDetector

use of org.gradle.internal.nativeintegration.console.ConsoleDetector in project gradle by gradle.

the class ConsoleConfigureAction method execute.

public void execute(OutputEventRenderer renderer, ConsoleOutput consoleOutput) {
    if (consoleOutput == ConsoleOutput.Plain) {
        return;
    }
    ConsoleDetector consoleDetector = NativeServices.getInstance().get(ConsoleDetector.class);
    ConsoleMetaData consoleMetaData = consoleDetector.getConsole();
    boolean force = false;
    if (consoleMetaData == null) {
        if (consoleOutput == ConsoleOutput.Auto) {
            return;
        }
        assert consoleOutput == ConsoleOutput.Rich;
        consoleMetaData = new FallbackConsoleMetaData();
        force = true;
    }
    boolean stdOutIsTerminal = consoleMetaData.isStdOut();
    boolean stdErrIsTerminal = consoleMetaData.isStdErr();
    int numWorkersToDisplay = ConsoleLayoutCalculator.calculateNumWorkersForConsoleDisplay(consoleMetaData);
    if (stdOutIsTerminal) {
        OutputStream originalStdOut = renderer.getOriginalStdOut();
        OutputStreamWriter outStr = new OutputStreamWriter(force ? originalStdOut : AnsiConsoleUtil.wrapOutputStream(originalStdOut));
        Console console = new AnsiConsole(outStr, outStr, renderer.getColourMap(), consoleMetaData, numWorkersToDisplay, force);
        renderer.addConsole(console, true, stdErrIsTerminal, consoleMetaData);
    } else if (stdErrIsTerminal) {
        // Only stderr is connected to a terminal
        OutputStream originalStdErr = renderer.getOriginalStdErr();
        OutputStreamWriter errStr = new OutputStreamWriter(force ? originalStdErr : AnsiConsoleUtil.wrapOutputStream(originalStdErr));
        Console console = new AnsiConsole(errStr, errStr, renderer.getColourMap(), consoleMetaData, numWorkersToDisplay, force);
        renderer.addConsole(console, false, true, consoleMetaData);
    }
}
Also used : FallbackConsoleMetaData(org.gradle.internal.nativeintegration.console.FallbackConsoleMetaData) ConsoleDetector(org.gradle.internal.nativeintegration.console.ConsoleDetector) OutputStream(java.io.OutputStream) Console(org.gradle.internal.logging.console.Console) AnsiConsole(org.gradle.internal.logging.console.AnsiConsole) FallbackConsoleMetaData(org.gradle.internal.nativeintegration.console.FallbackConsoleMetaData) ConsoleMetaData(org.gradle.internal.nativeintegration.console.ConsoleMetaData) OutputStreamWriter(java.io.OutputStreamWriter) AnsiConsole(org.gradle.internal.logging.console.AnsiConsole)

Example 3 with ConsoleDetector

use of org.gradle.internal.nativeintegration.console.ConsoleDetector in project gradle by gradle.

the class ConsoleConfigureAction method configureRichConsole.

private static void configureRichConsole(OutputEventRenderer renderer, boolean verbose) {
    ConsoleDetector consoleDetector = NativeServices.getInstance().get(ConsoleDetector.class);
    ConsoleMetaData consoleMetaData = consoleDetector.getConsole();
    configureRichConsole(renderer, consoleMetaData, consoleMetaData == null, verbose);
}
Also used : ConsoleDetector(org.gradle.internal.nativeintegration.console.ConsoleDetector) FallbackConsoleMetaData(org.gradle.internal.nativeintegration.console.FallbackConsoleMetaData) ConsoleMetaData(org.gradle.internal.nativeintegration.console.ConsoleMetaData)

Example 4 with ConsoleDetector

use of org.gradle.internal.nativeintegration.console.ConsoleDetector in project gradle by gradle.

the class ConsoleConfigureAction method configureAutoConsole.

private static void configureAutoConsole(OutputEventRenderer renderer) {
    ConsoleDetector consoleDetector = NativeServices.getInstance().get(ConsoleDetector.class);
    ConsoleMetaData consoleMetaData = consoleDetector.getConsole();
    if (consoleMetaData != null) {
        configureRichConsole(renderer, consoleMetaData, false, false);
    } else {
        configurePlainConsole(renderer);
    }
}
Also used : ConsoleDetector(org.gradle.internal.nativeintegration.console.ConsoleDetector) FallbackConsoleMetaData(org.gradle.internal.nativeintegration.console.FallbackConsoleMetaData) ConsoleMetaData(org.gradle.internal.nativeintegration.console.ConsoleMetaData)

Aggregations

ConsoleDetector (org.gradle.internal.nativeintegration.console.ConsoleDetector)4 ConsoleMetaData (org.gradle.internal.nativeintegration.console.ConsoleMetaData)4 FallbackConsoleMetaData (org.gradle.internal.nativeintegration.console.FallbackConsoleMetaData)3 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 AnsiConsole (org.gradle.internal.logging.console.AnsiConsole)1 Console (org.gradle.internal.logging.console.Console)1