Ant脚本:让标记转储整个命令行

我有一个ant构建脚本,其中包含一个相当复杂的命令,其中包含许多标记,我正在尝试进行故障排除。 我想知道在构建它之后是否可以查看整个命令行; 可以在eclipse调试器中,也可以将其转储到文件中。

这是我正在处理的事情:

                         <!--         -->                                             

这是我得到的错误:

 BUILD FAILED C:\dev\workspace\rmsitepi2\build.raytheon.suite.tomcat.xml:50: The following error occurred while executing this line: C:\dev\workspace\rmsitepi2\build.raytheon.flex.xml:33: The following error occurred while executing this line: C:\dev\workspace\rmsitepi2\build.raytheon.flex.xml:159: exec returned: 1 

ant -v通常可以解决这个问题,但是你可能会发现你有很多输出需要查看。

一些好老的回声通过:

    ...   

在激活真实的东西之前测试你的东西(属性值,属性已解决……等)!
这就是我经常使用的,因为ant -verbose | 当我只需要检查特定部分时,调试就是聊天。 然后简单地删除或评论echoxml标签。
对于echoxml,您需要Ant> = 1.7

尝试使用log4j ANT监听器 。 它可以配置为在Exec任务输出上为零。

项目文件

 $ tree . |-- build.xml `-- lib |-- log4j-1.2.16.jar `-- log4j.properties 1 directory, 3 files 

build.xml文件

        

log4j.properties

 log4j.rootLogger=ERROR, LogFile log4j.logger.org.apache.tools.ant.taskdefs.ExecTask=DEBUG log4j.appender.LogFile=org.apache.log4j.FileAppender log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout log4j.appender.LogFile.layout.ConversionPattern=[%6r] %8c{1} : %m%n log4j.appender.LogFile.file=build.log 

运行构建

需要指定监听器和包含log4j依赖关系的目录:

 ant -listener org.apache.tools.ant.listener.Log4jListener -lib lib 

build.log文件中生成以下输出

 $ cat build.log [ 0] ExecTask : Current OS is Linux [ 14] ExecTask : Executing 'echo' with arguments: 'hello' 'world' The ' characters around the executable and arguments are not part of the command. [ 20] ExecTask : hello world