Как раскрасить выход Gradle с помощью sed? - PullRequest
0 голосов
/ 10 октября 2018

Я пытаюсь обработать sed следующий вывод оболочки из Gradle для распознавания и раскраски уровней серьезности:

23:06:28.686 [LIFECYCLE] [system.out] 
23:06:28.686 [QUIET] [system.out] Note: the configuration keeps the entry point 'androidx.core.graphics.drawable.IconCompatParcelizer { android.support.v4.graphics.drawable.IconCompat read(androidx.versionedparcelable.VersionedParcel); }', but not the descriptor class 'androidx.versionedparcelable.VersionedParcel'
23:06:28.686 [QUIET] [system.out] Note: the configuration keeps the entry point 'androidx.core.graphics.drawable.IconCompatParcelizer { void write(android.support.v4.graphics.drawable.IconCompat,androidx.versionedparcelable.VersionedParcel); }', but not the descriptor class 'androidx.versionedparcelable.VersionedParcel'
23:06:28.710 [QUIET] [system.out] Note: there were 5 references to unknown classes.
23:06:28.711 [QUIET] [system.out]       You should check your configuration for typos.
23:06:28.711 [QUIET] [system.out]       (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
23:06:28.711 [QUIET] [system.out] Note: there were 2 unkept descriptor classes in kept class members.
23:06:28.711 [QUIET] [system.out]       You should consider explicitly keeping the mentioned classes
23:06:28.711 [QUIET] [system.out]       (using '-keep').
23:06:28.711 [QUIET] [system.out]       (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
23:06:28.711 [QUIET] [system.out] Note: there were 12 unresolved dynamic references to classes or interfaces.
23:06:28.711 [QUIET] [system.out]       You should check if you need to specify additional program jars.
23:06:28.711 [QUIET] [system.out]       (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
23:06:28.711 [ERROR] [system.err] Warning: there were 11 unresolved references to classes or interfaces.
23:06:28.711 [ERROR] [system.err]          You may need to add missing library jars or update their versions.
23:06:28.711 [ERROR] [system.err]          If your code works fine without the missing classes, you can suppress
23:06:28.711 [ERROR] [system.err]          the warnings with '-dontwarn' options.
23:06:28.711 [ERROR] [system.err]          (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
23:06:28.711 [QUIET] [system.out] Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
23:06:28.585 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] 

Я использую следующую оболочкускрипт:

#!/bin/sh

c_red=`tput setaf 1`
c_end=`tput sgr0`
./gradlew --info --debug assemble | sed -E -e "s/(\[ERROR\])/${c_red}\1${c_end}/g" \

Вот скриншот необработанного вывода:

Unprocessed output

Вот скриншот обработанного вывода:

Processed output

Помимо отсутствующего цвета, я заметил, что некоторые строки вывода потеряны в обработанном выводе.Кроме того, сам Gradle, похоже, раскрасит определенное слово, как можно увидеть в необработанном выводе.Управляющие символы из Gradle и то, что я использую в команде sed , могут мешать .

Если я выберу LIFECYCLE вместо ERROR, сценарий будет работать несколько,Там тоже потеряны некоторые строки!И цветовая гамма исчезает.

Processed output: LIFECYCLE

Я запускаю это на терминале в Ubuntu 16.04.

...