Search code examples
javaterminalcolorsant

customize the color of AnsiColorLogger in ant?


Currently my ant output is colorized by AnsiColorLogger. It works as expected, and now I want to customize the colors (default ones are too dim). I created a color file as specified, but have no idea how to pass the file name through. The documentation says

This file must be specified as the value of a system variable named ant.logger.defaults and passed as an argument using the -D option to the java command that invokes the Ant application.

How to pass an argument to the java command if I just run on terminal with ant? I tried to pass

-Dant.logger.defaults=<my file path>

to ant but no luck. I also tried setting environment variable

ANT_OPTS='-Dant.logger.defaults=<my file path>'

but it didn't work either. In case it matters, I am with

  • OS X 10.10.5
  • Apache Ant(TM) version 1.9.6
  • Java 1.8.0_65

Solution

  • I found my bug: my path to the file was ~/my-file but ~ in single quotes is not expanded. That simple.

    (I forgot the fact that when I use ~ in terminal, it is expanded by the shell before passed to the program.)