简体   繁体   中英

pass arguments to java through ant

I want to pass command line arguments to my java program that is invoked through a fake ant (we have our own ant script in perl which at some point calls the actual ant). So what I want to do is invoke my program like this :

./ant program_name arg1 arg2

Right now I have an ant target for my program but instead of passing the arguments from the command line I am hard-coding them into the build file like this :

<arg line="arg1 arg2"/>

Any ideas on how can I use variables in the build file and load them from the command line arguments and then use them in my java program ?

The easiest might be to have your script turn then into system properties through -D .

Your ant build file can then use those to set ant properties that can be set in the <arg> tag (or referenced directly, although my preference would be to set ant properties, but that may be more out of habit than for any technical reason).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM