Real time ant build analyzer

拈花ヽ惹草 提交于 2019-12-13 02:26:01

问题


Is there any Ant tool to Analyze Ant build activities during run time? Due to lack of time i don;t want to go through each line of code in the ant script to understand what it is doing. It would be great if i can get any suggestions for anysuch tools.


回答1:


Check out the ANT documentation on ANT loggers and listeners.

To print everything that ANT is doing I'd suggest using the very powerful log4j listener.

Example

The log4j listener needs some setup. Example can be run as follows:

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

It generates a log file with detailing each step within the build:

[     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.

build.xml

<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>


来源:https://stackoverflow.com/questions/12055760/real-time-ant-build-analyzer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!