4

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

Tom Tresansky
  • 19,364
  • 17
  • 93
  • 129
  • Yes - I made a macrodef to forward ant targets to another script and would be nice to do things like this: ... – peterk Apr 07 '13 at 17:15

2 Answers2

2

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
JoseK
  • 31,141
  • 14
  • 104
  • 131
  • Thanks for the link to the discussion, it was helpful reading to gain a perspective. Unfortunately, I don't think a listener is what I'm after. I had assumed that since the project name and invoked targets were get-able, the current target would be as well, and that I was just missing a property somewhere. – Tom Tresansky Jun 22 '10 at 16:29
1

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.

Community
  • 1
  • 1
Patrice M.
  • 4,209
  • 2
  • 27
  • 36