Search in sources :

Example 1 with TextStream

use of org.gradle.internal.io.TextStream in project gradle by gradle.

the class InProcessGradleExecuter method createLoggingManager.

private LoggingManagerInternal createLoggingManager(StartParameter startParameter, final StandardOutputListener outputListener) {
    LoggingManagerInternal loggingManager = GLOBAL_SERVICES.getFactory(LoggingManagerInternal.class).create();
    loggingManager.captureSystemSources();
    ConsoleOutput consoleOutput = startParameter.getConsoleOutput();
    if (consoleOutput == ConsoleOutput.Auto) {
        // IDEA runs tests attached to a console, use plain so test can assume never attached to a console
        // Should really run all tests against a plain and a rich console to make these assumptions explicit
        consoleOutput = ConsoleOutput.Plain;
    }
    loggingManager.attachConsole(new TeeOutputStream(System.out, new LineBufferingOutputStream(new TextStream() {

        @Override
        public void text(String text) {
            outputListener.onOutput(text);
        }

        @Override
        public void endOfStream(@Nullable Throwable failure) {
        }
    })), consoleOutput);
    return loggingManager;
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) ConsoleOutput(org.gradle.api.logging.configuration.ConsoleOutput) TeeOutputStream(org.apache.commons.io.output.TeeOutputStream) LineBufferingOutputStream(org.gradle.internal.io.LineBufferingOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) TextStream(org.gradle.internal.io.TextStream)

Aggregations

TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 ConsoleOutput (org.gradle.api.logging.configuration.ConsoleOutput)1 LineBufferingOutputStream (org.gradle.internal.io.LineBufferingOutputStream)1 TextStream (org.gradle.internal.io.TextStream)1 LoggingManagerInternal (org.gradle.internal.logging.LoggingManagerInternal)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1