novice
novice

Reputation: 53

can we pass command line argument to ant target

How can we pass command line argument to ant target

for example I have target in build.xml defined as below

 <target name="test">
      <echo>Hello,</echo>
   </target>

if I invoke ant as cmd>ant -buildfile build.xml test USERNAME

It should print echo as "Hello, USERNAME"

is it possible some way? Thanks in advance for help

Upvotes: 0

Views: 476

Answers (1)

howlger
howlger

Reputation: 34135

ant -buildfile build.xml test USERNAME would mean run the two targets, test and USERNAME (see Ant manual).

Instead, do ant -buildfile build.xml -Dname=USERNAME test and

<target name="test">
    <echo>Hello, ${name}</echo>
</target>

Upvotes: 0

Related Questions