Reputation: 1962
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 ?
Upvotes: 5
Views: 2179
Reputation: 160170
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).
Upvotes: 4