When i run a class that outputs colour (using jansi) via a gradle JavaExec task, all of the escape sequences are lost. It works fine if I invoke the class directly from java.
For example
class AnsiConsoleTest {
def static main(args) {
AnsiConsole.systemInstall()
System.out.println( ansi().render("@|red Hello|@ @|green World|@") )
}
}
Using the following task:
task runConsoleTest(type: JavaExec, dependsOn: "classes") {
description = "Runs the Ansi Console Tester"
main = 'AnsiConsoleTest'
classpath configurations.compile, configurations.runtime, sourceSets.main.output
}
and invoking gives:
$ gradle runConsoleTest
:compileJava UP-TO-DATE
:compileGroovy
:processResources UP-TO-DATE
:classes
:runConsoleTest
Hello World
BUILD SUCCESSFUL
Total time: 5.437 secs
where the UP-TO-DATE messages are coloured correctly, but my output is not.
Is there a way to get it to work via the gradle task invocation?
I did a search on forums, but the only thing I could find vaguely related to colour issues was this feature request: http://forums.gradle.org/gradle/topics/feature_request_force_color_option_color
but this doesn’t appear to be my problem, I am seeing colour in the build process, just not on execution of my class.
Thanks, Mark