ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject RE: Reading target name
Date Sat, 20 Jul 2002 03:03:28 GMT
--- Dominique Devienne <DDevienne@lgc.com> wrote:
> You'll need to drop js.jar and bsf.jar in ${ant.home}/lib for the
> following to work.
[snip script to get target name]

Or you can use my exceedingly naughty task, which gets the current
target's name and sets a property to that name. (It's naughty because you
can use the same property over and over again :) For example:

  <taskdef name="gettarget" classname="GetTarget"/>
  <target name="main" depends="t1,t2">
    <gettarget property="target"/>
    <echo>target = ${target}</echo>
  </target>

  <target name="t1">
    <gettarget property="target"/>
    <echo>target = ${target}</echo>
  </target>

  <target name="t2">
    <gettarget property="target"/>
    <echo>target = ${target}</echo>
  </target>

$ ant
t1:
     [echo] target = t1

t2:
     [echo] target = t2

main:
     [echo] target = main

Actually, I just made it even naughtier by hard-coding in "target" as a
default name for the property if one's not specified :)

If you want the source (and/or jar), just let me know.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message