如何在 MSYS/Git Bash 中查看彩色 Ant 输出?
我想使用 AnsiColorLogger 从 蚂蚁。我在 Windows 上使用 Git Bash。
我尝试过:
$ ant -logger org.apache.tools.ant.listener.AnsiColorLogger
但我的输出看起来像:
Buildfile: c:\foo\build.xml
←[2;36m [junit] Testsuite: org.foo.BarTest←[m
←[2;36m [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.188 sec←[m
←[2;36m [junit] ←[m
←[2;36m [junit] Testcase: testInherits took 0.175 sec←[m
←[2;36m [junit] FAILED←[m
←[2;36m [junit] subdir not child←[m
←[2;36m [junit] junit.framework.AssertionFailedError: subdir not child←[m
←[2;36m [junit] at org.foo.BarTest.testInherits(BarTest.java:61)←[m
←[2;36m [junit] ←[m
←[2;31m [junit] Test org.foo.BarTest FAILED←[m
我知道 ANSI 颜色在 Git Bash 中至少部分有效,因为像 ls -ACF --color=auto 之类的命令会产生漂亮的彩色输出。
Ant有什么技巧呢?
I'd like to use AnsiColorLogger to get color ouput from Ant. I'm using Git Bash on Windows.
I tried:
$ ant -logger org.apache.tools.ant.listener.AnsiColorLogger
but my output looks like:
Buildfile: c:\foo\build.xml
←[2;36m [junit] Testsuite: org.foo.BarTest←[m
←[2;36m [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.188 sec←[m
←[2;36m [junit] ←[m
←[2;36m [junit] Testcase: testInherits took 0.175 sec←[m
←[2;36m [junit] FAILED←[m
←[2;36m [junit] subdir not child←[m
←[2;36m [junit] junit.framework.AssertionFailedError: subdir not child←[m
←[2;36m [junit] at org.foo.BarTest.testInherits(BarTest.java:61)←[m
←[2;36m [junit] ←[m
←[2;31m [junit] Test org.foo.BarTest FAILED←[m
I know ANSI colors work, at least partially, in Git Bash because commands like ls -ACF --color=auto
produce nicely colored output.
What's the trick for Ant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过大量的谷歌搜索和实验,我将几种变体组合成一个解决方案,该解决方案非常适合 Git Bash、Ant 和 Windows 的特定组合。
将以下行添加到
.bashrc
文件后重新启动 Git Bash:Git Bash Noob 提示:
.bashrc
文件(如果存在)位于你的主目录。创建/编辑它的方法如下:After much Googling and experimentation, I combined several variations into a solution that works well for the particular combination of Git Bash, Ant and Windows.
Relaunch Git Bash after adding the following lines to your
.bashrc
file:Git Bash Noob Tip:
.bashrc
file, if it exists, lives in your home directory. Here's how to create/edit it:设置环境变量 ANT_ARGS 可能更容易。
例如,只需将其放入您的 .bashrc 中:
it's probably even easier to just set the environment variable ANT_ARGS.
e.g. just put this in your .bashrc: