diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt index 7e964e92695..aa7139260d7 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt @@ -142,6 +142,9 @@ abstract class CLITool { if (System.getProperty("java.awt.headless") == null) { System.setProperty("java.awt.headless", "true") } + if (System.getProperty(PlainTextMessageRenderer.KOTLIN_COLORS_ENABLED_PROPERTY) == null) { + System.setProperty(PlainTextMessageRenderer.KOTLIN_COLORS_ENABLED_PROPERTY, "true") + } val exitCode = doMainNoExit(compiler, args) if (exitCode != ExitCode.OK) { System.exit(exitCode.code) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java index 03edd893fd1..7471c8c1e03 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java @@ -30,12 +30,13 @@ import java.util.Set; import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*; public abstract class PlainTextMessageRenderer implements MessageRenderer { + public static final String KOTLIN_COLORS_ENABLED_PROPERTY = "kotlin.colors.enabled"; public static final boolean COLOR_ENABLED; static { boolean colorEnabled = false; // TODO: investigate why ANSI escape codes on Windows only work in REPL for some reason - if (!SystemInfo.isWindows && !"false".equals(System.getProperty("kotlin.colors.enabled"))) { + if (!SystemInfo.isWindows && "true".equals(System.getProperty(KOTLIN_COLORS_ENABLED_PROPERTY))) { try { // AnsiConsole doesn't check isatty() for stderr (see https://github.com/fusesource/jansi/pull/35). colorEnabled = CLibrary.isatty(CLibrary.STDERR_FILENO) != 0;