在运行时是否有任何Ant工具来分析Ant构建活动?由于时间不够,我不想通过ant脚本中的每行代码来了解它在做什么。如果我能得到任何关于这类工具的建议,那就太棒了。
答案 0 :(得分:1)
查看ANT loggers and listeners上的ANT文档。
要打印ANT正在做的所有事情,我建议使用非常强大的log4j监听器。
log4j监听器需要一些设置。示例可以按如下方式运行:
ant bootstrap
ant -listener org.apache.tools.ant.listener.Log4jListener -lib .
它生成一个日志文件,详细说明构建中的每个步骤:
[ 0] Project : Build started.
[ 94] Target : Target "run1" started.
[ 319] Echo : Run1: Hello world
[ 320] Target : Target "run1" finished.
[ 320] Target : Target "run2" started.
[ 321] Echo : Run2: Hello world
[ 321] Target : Target "run2" finished.
[ 321] Target : Target "run" started.
[ 321] Target : Target "run" finished.
[ 328] Project : Build finished.
<project name="ANT listener" default="run">
<target name="bootstrap">
<get src="http://search.maven.org/remotecontent?filepath=log4j/log4j/1.2.17/log4j-1.2.17.jar" dest="log4j.jar"/>
<echo file="log4j.properties">
log4j.rootLogger=ERROR, LogFile
log4j.logger.org.apache.tools.ant.Project=INFO
log4j.logger.org.apache.tools.ant.Target=INFO
log4j.logger.org.apache.tools.ant.taskdefs=INFO
log4j.logger.org.apache.tools.ant.taskdefs.Echo=WARN
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
</echo>
</target>
<target name="run" depends="run1,run2">
</target>
<target name="run1">
<echo message="Run1: Hello world"/>
</target>
<target name="run2">
<echo message="Run2: Hello world"/>
</target>
</project>