ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject RE: Reading target name
Date Sat, 20 Jul 2002 03:03:28 GMT
--- Dominique Devienne <> 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 name="t1">
    <gettarget property="target"/>
    <echo>target = ${target}</echo>

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

$ ant
     [echo] target = t1

     [echo] target = t2

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



Do You Yahoo!?
Yahoo! Health - Feel better, live better

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message