Print/Access the Name of the Currently Executing Ant Target [duplicate]

那年仲夏 提交于 2019-12-23 12:15:32

问题


How do I do this within my build file? Say I just want to <echo/> the name?


回答1:


There is no built-in property for the current executing target name. Some debate on this is here.

If you configure ant with log4j as a listener like this, the output will display each target start and end like below. Calling ant build:

D:\apache-ant-1.8.0RC1\bin>ant -lib D:\log4j\log4j\1.2.13 -listener org.apache.tools.ant.listener.Log4jListener build
Buildfile: D:\apache-ant-1.8.0RC1\bin\build.xml
11:39:34 INFO  Build started.

build:
11:39:34 INFO  Target "build" started.
      [echo] 100
11:39:34 INFO  Updating property file: D:\abc.properties
 [propertyfile] Updating property file: D:\abc.properties
 11:39:35 INFO  Target "build" finished.

BUILD SUCCESSFUL
Total time: 0 seconds



回答2:


I think this answer to pretty much the same question is more satisfactory, with a ready-to use macro to extract the value whenever necessary.



来源:https://stackoverflow.com/questions/3084946/print-access-the-name-of-the-currently-executing-ant-target

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