Skip to content

Instantly share code, notes, and snippets.

@Querela
Last active December 27, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Querela/7315123 to your computer and use it in GitHub Desktop.
Save Querela/7315123 to your computer and use it in GitHub Desktop.
[*nix][shell][script][java][build] Colorize ant output and remove warnings.Usage: antx.sh <anttarget>
#!/bin/bash
# colorizes an ant command
anttask="$1"
#####################################################################
echo -e "\033[31m### ANTTASK: ant $anttask ###\033[30m"
# Process command output
ant $anttask 2>&1 | while read line
do
# ignore warnings
if [ "$line" != "${line/Trying to override old definition of/}" ]; then
continue
fi
# color all output in the format: "[xxx] xxx" -> braces
line="${line//[/\033[34m[}"
line="${line//]/]\033[33m}"
# color the result
if [ "$line" != "${line/BUILD/}" ]; then
if [ "$line" != "${line/SUCCESSFUL/}" ]; then
# successful
line="${line/BUILD/\033[42m\033[31m### BUILD} ###"
else
# failed
line="${line/BUILD/\033[40m\033[31m### BUILD} ###"
fi
fi
# echo line
echo -e $line "\033[30m\033[49m"
done
#echo -e "\033[0m\033[49m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment