Enable colors for logging in terminal for Windows in mintty for Spring Boot.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 22 Feb 2017 10:23:40 +0200
changeset 837 4ba0fe28be27
parent 836 ed2feb95716d
child 838 98cdbead06be
Enable colors for logging in terminal for Windows in mintty for Spring Boot.
.gradle/init.d/springColorLogging.gradle
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gradle/init.d/springColorLogging.gradle	Wed Feb 22 10:23:40 2017 +0200
@@ -0,0 +1,12 @@
+gradle.taskGraph.whenReady { graph ->
+    // graph.getAllTasks().findAll().each { println it }
+    def console = System.console() != null
+    if (! console) { console = System.getenv()["TERM"].startsWith("xterm") }
+    if (! console) return
+    graph.getAllTasks().findAll({it.name.equals("bootRun")}).each {
+        it.systemProperties 'spring.output.ansi.enabled': 'always'
+        // it.metaClass.methods*.name.sort().unique().each { println it }
+    };
+    // graph.metaClass.properties.each { println it }
+    // graph.metaClass.methods*.name.sort().unique().each { println it }
+}