I know that some questions have been asked about how to hook into gradle’s color output – but I have not yet seen a question/answer about how to simply detect gradle’s color settings.
I have a test listener that outputs test results more concisely than the built in gradle test events do (it was originally a test listener for testng). I’m trying to get this listener to hook into gradle’s “–no-color” option rather than inventing a new -Dcolor=false system property to turn off color.
I don’t understand the question. Are you trying to disable colors for parts of the output? Not sure that’s possible. And how is this related to your listener?
I’m trying to detect whether gradle itself is in “color” or “–no-color” mode or not, so that I can adjust my custom test listener to use color or not based on gradle’s color setting.
You can detect whether ‘–no-color’ was passed via ‘gradle.startParameter.isColorOutput()’. However, I’m not aware of a public API to determine whether Gradle considers the current terminal to be capable of displaying colors.