ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: Property of used target
Date Wed, 13 Feb 2002 22:49:35 GMT
--- Michael Wenig <> wrote:
> I have a script which builds distributables for 2 systems (production
> and test-system).
> Which system will be used depends on command-line-called target. Because
> there are differences between these distributables (e.g.
> deployment-descriptors) I want to include the target given on
> command-line in the name of the resulting jar/war, without using another
> internal target to pack - this would result in much redundancy.
> I thought of a built-in-property like so I can use
> <jar jarfile="${dist}/project-${}.jar"
> basedir="${dest}"/>
> so calling "ant test" would result in "project-test.jar" and calling
> "ant production" would result in "project-production.jar" without
> defining two different targets which do the packing.
> Does anyone know if this is possible?

There isn't a built-in property for the target, but you could do something
in .antrc (which the 'ant' script processes):

for arg in $*
  [ "$targetset" ] && {
    echo "Error: Only one of production | test may be specified."
    exit 1
  case $arg in
    production) export ANT_OPTS="$ANT_OPTS -Dtarget=$arg"
          test) export ANT_OPTS="$ANT_OPTS -Dtarget=$arg"

Of course, that's just for *nix (or Win* running *nix-type shells), so if
you're on a straight Win* box, you're on your own :)



Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!

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

View raw message